Ejemplo n.º 1
0
        public static StatServerItem GetServerStatictic(int ms, string cs)
        {
            var item = new StatServerItem();

            using (var ctx = new ExchangeDataContext(cs))
            {
                var orders = ctx.Orders.Where(x =>
                                              x.DealDate > DateTime.Now.AddMilliseconds(-ms));

                if (orders.Any())
                {
                    item.DealCount = orders.Count();
                    item.DealValue = orders.Sum(y => y.DealValue);
                }

                var srv = ctx.ServerLogs.OrderByDescending(x => x.EventDate)
                          .FirstOrDefault(x => x.EventTypeId == (int)EventTypeEnum.Running &&
                                          x.EventDate > DateTime.Now.AddMilliseconds(-ms));

                if (srv != null)
                {
                    item.ServerName        = srv.ServerId.ToString();
                    item.IsServerAvailable = true;

                    var start = ctx.ServerLogs.FirstOrDefault(x =>
                                                              x.EventTypeId == (int)EventTypeEnum.Started &&
                                                              x.ServerId == srv.ServerId);

                    if (start != null)
                    {
                        TimeSpan diff = DateTime.Now - start.EventDate;
                        item.ServerWorkingHours   = diff.Hours;
                        item.ServerWorkingMinutes = diff.Minutes;
                        item.ServerWorkingSeconds = diff.Seconds;
                    }

                    item.ClientCount = srv.AvailableClientsCount;
                }
            }
            return(item);
        }
Ejemplo n.º 2
0
 public Monitor()
 {
     Id         = Guid.NewGuid();
     Statistic  = new List <StatItem>();
     StatServer = new StatServerItem();
 }