Exemple #1
0
        public QueueStat(Queue queue)
        {
            var avgin = (db.Processing.Where(p => p.ProcUserComplete >= DbFunctions.AddDays(DateTime.Now, -60) && p.Username != null).Average(p => DbFunctions.DiffDays(p.ProcInQueue, p.ProcUserComplete))) / 24;

            Priorities     = db.Processing.Where(p => p.ProcUserComplete == null && p.Record.ProcPriority == true && p.QueueID == queue.QueueID).Count();
            this.queue     = queue;
            fileTypeAmount = new List <StringAndInt>();
            var data = db.Processing.Include(p => p.Record.FileType).Where(p => p.ProcUserComplete == null && p.QueueID == queue.QueueID).ToList();

            queueAmount = data.Count();
            var i = data.Select(p => p.Record.FileType).Distinct().ToList();

            highestTypeAmount = -1;
            foreach (var item in i)
            {
                var x = new StringAndInt();
                x.MyString = item.TypeDescription;
                x.MyInt    = data.Where(p => p.Record.FileTypeID == item.FileTypeID).Count();
                if (x.MyInt > highestTypeAmount)
                {
                    highestTypeAmount = x.MyInt;
                }
                fileTypeAmount.Add(x);
            }
            var avg = (db.Processing.Where(p => p.ProcUserComplete >= DbFunctions.AddDays(DateTime.Now, -60) && p.Username != null && p.QueueID == queue.QueueID).Average(p => DbFunctions.DiffDays(p.ProcInQueue, p.ProcUserComplete)));

            if (avg == null)
            {
                AvgQueueTime = 0;
            }
            else
            {
                AvgQueueTime = Math.Round((double)avg, 2);
            }
        }
        private List <StringAndInt> FindNotComplete()
        {
            var processed = db.ProcessingError.Include(p => p.Processing).Include(p => p.ErrorComplete).Where(p => p.Processing.Username == username && p.DateComplete == null);
            IQueryable <StringAndInt> r = from err in processed
                                          group err by err.ErrorType.Description into errGroup
                                          orderby errGroup.Key
                                          select new StringAndInt {
                MyString = errGroup.Key, MyInt = errGroup.Count()
            };
            var          re = r.ToList();
            StringAndInt i  = new StringAndInt();

            i.MyString = "Total Errors Not Completed";
            i.MyInt    = processed.Select(p => p.Processing).Distinct().Count();
            re.Add(i);
            return(re);
        }
Exemple #3
0
        public UserStat(User user)
        {
            this.user     = user;
            typeCount     = new List <StringAndInt>();
            filingCabinet = db.Processing.Where(p => p.Username == user.Username && p.ProcUserComplete == null && p.InFilingCabinet == true).Count();
            var data = db.Processing.Include(p => p.Record.FileType).Where(p => p.Username == user.Username && p.ProcUserComplete >= DateTime.Today);

            var i = data.Select(p => p.Record.FileType).Distinct().ToList();

            foreach (var item in i)
            {
                var x = new StringAndInt();
                x.MyString = item.TypeDescription;
                x.MyInt    = data.Where(p => p.Record.FileTypeID == item.FileTypeID).Count();
                typeCount.Add(x);
            }
            Helpers h = new Helpers();

            processedToday = h.WeightedFileAmount(DateTime.Today, DateTime.Today.AddDays(1), user.Username);
        }
        private List <StringAndInt> FindNotAtFault(int days)
        {
            DateTime FirstDate          = db.Hour.Where(p => p.Username == username).OrderByDescending(p => p.HourDate).First().HourDate.AddDays(-days);
            DateTime LastDate           = db.Hour.Where(p => p.Username == username).OrderByDescending(p => p.HourDate).First().HourDate.AddDays(1);
            var      dtdays             = db.Hour.Where(p => p.Username == username).OrderByDescending(p => p.HourDate).First().HourDate.AddDays(-days);
            var      processed          = db.ProcessingError.Include(p => p.Processing).Include(p => p.ErrorComplete).Where(p => p.Processing.Username == username && p.DateComplete >= FirstDate && p.DateComplete < LastDate && !p.ErrorComplete.Counted);
            IQueryable <StringAndInt> r = from err in processed
                                          group err by err.ErrorComplete.Description into errGroup
                                          orderby errGroup.Key
                                          select new StringAndInt {
                MyString = errGroup.Key, MyInt = errGroup.Count()
            };
            var          re = r.ToList();
            StringAndInt i  = new StringAndInt();

            i.MyString = "Total Not At Fault";
            i.MyInt    = processed.Select(p => p.Processing).Distinct().Count();
            re.Add(i);
            return(re);
        }
        public MetricProgressViewModel(string username)
        {
            this.username = username;
            if (db.Hour.Where(p => p.Username == username).Count() == 0)
            {
                FilesProcessed14Day = new List <StringAndInt>();
                FilesProcessed28Day = new List <StringAndInt>();
                FilesProcessed56Day = new List <StringAndInt>();
                var xxx = new StringAndInt();
                xxx.MyString = "N/A";
                xxx.MyInt    = 0;
                error14      = new List <StringAndInt>();
                error14.Add(xxx);
                error28 = new List <StringAndInt>();
                error28.Add(xxx);
                error56 = new List <StringAndInt>();
                error56.Add(xxx);
                nerror14     = new List <StringAndInt>();
                nerror28     = new List <StringAndInt>();
                nerror56     = new List <StringAndInt>();
                notComplete  = new List <StringAndInt>();
                PerHour14    = 0;
                PerHour28    = 0;
                PerHour56    = 0;
                ErrPercent14 = 0;
                ErrPercent28 = 0;
                ErrPercent56 = 0;
                LastUpdated  = new DateTime();
                return;
            }
            LastUpdated = db.Hour.Where(p => p.Username == username).OrderByDescending(p => p.HourDate).First().HourDate;
            PerHour14   = 0;
            PerHour28   = 0;
            PerHour56   = 0;

            #region FilesProcessed
            FilesProcessed14Day = FindFiles(14);
            PerHour14           = WeightedAverageFile(FilesProcessed14Day, 14);
            FilesProcessed28Day = FindFiles(28);
            PerHour28           = WeightedAverageFile(FilesProcessed28Day, 28);
            FilesProcessed56Day = FindFiles(56);
            PerHour56           = WeightedAverageFile(FilesProcessed56Day, 56);
            #endregion

            #region Errors On Files
            error14     = FindErrors(14);
            error28     = FindErrors(28);
            error56     = FindErrors(56);
            nerror14    = FindNotAtFault(14);
            nerror28    = FindNotAtFault(28);
            nerror56    = FindNotAtFault(56);
            notComplete = FindNotComplete();
            #endregion
            #region Overview

            ErrPercent14 = FilesProcessed14Day.Sum(p => p.MyInt);
            ErrPercent28 = FilesProcessed28Day.Sum(p => p.MyInt);
            ErrPercent56 = FilesProcessed56Day.Sum(p => p.MyInt);
            if (ErrPercent14 > 0)
            {
                ErrPercent14 = error14.Last().MyInt / ErrPercent14 * 100;
            }
            if (ErrPercent28 > 0)
            {
                ErrPercent28 = error28.Last().MyInt / ErrPercent28 * 100;
            }
            if (ErrPercent56 > 0)
            {
                ErrPercent56 = error56.Last().MyInt / ErrPercent56 * 100;
            }
            #endregion
        }