Ejemplo n.º 1
0
        // GET: /<controller>/
        public async Task <IActionResult> Index()
        {
            var partyList = new List <PartyModel>();

            var parties = await _cache.GetAsync <Dictionary <string, string> >("ConnectionIndex") ?? new Dictionary <string, string>();

            foreach (var partyName in parties.Select(t => t.Value).Distinct().ToList())
            {
                var party = await _cache.GetAsync <PartyModel>($"party:{partyName}");

                if (party != null)
                {
                    party.Players.Select(t => {
                        t.Character.Items   = null;
                        t.NetWorthSnapshots = null;
                        t.PastAreas         = null;
                        return(t);
                    }).ToList();
                    partyList.Add(party);
                }
            }

            StatisticsModel stats = await _cache.GetAsync <StatisticsModel>("Statistics");

            var response = new
            {
                Statistics = stats,
                Parties    = partyList
            };

            return(Ok(response));
        }
Ejemplo n.º 2
0
 public void RenderEndGame(StatisticsModel statistics, double time)
 {
     Console.WriteLine("Words per minute: " + statistics.GetNetWpm());
     Console.WriteLine("Correct words: " + statistics.GetCorrectWords());
     Console.WriteLine("Mistake count: " + statistics.GetErrorCount());
     Console.WriteLine("Elapsed time: " + time + " seconds");
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutStatisticsModel(int id, StatisticsModel statisticsModel)
        {
            if (id != statisticsModel.Id)
            {
                return(BadRequest());
            }

            _context.Entry(statisticsModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StatisticsModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 4
0
        public async Task <ActionResult <StatisticsModel> > PostStatisticsModel(StatisticsModel statisticsModel)
        {
            _context.StatisticsModels.Add(statisticsModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetStatisticsModel", new { id = statisticsModel.Id }, statisticsModel));
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            GameRenderer renderer = new GameRenderer();

            GivenWordsModel givenWords = new GivenWordsModel();

            PlayerModel player = new PlayerModel();

            GameRules gameRules = new GameRules(player, givenWords);

            ClockModel clock = new ClockModel();

            renderer.RenderGameStart();
            clock.StartClock();
            while (!gameRules.GetGameStatus())
            {
                renderer.RenderClearConsole();
                renderer.RenderCurrentWords(givenWords);
                renderer.RenderPlayerInput(player);

                ConsoleKeyInfo userKey = Console.ReadKey();
                gameRules.CheckPlayerInput(userKey);
                gameRules.CheckGameOver();
            }
            clock.StopClock();

            StatisticsModel statistics = new StatisticsModel(givenWords, player, clock.GetTimeInMinutes());

            renderer.RenderEndGame(statistics, clock.GetTimeInSeconds());
            Console.ReadKey();
        }
Ejemplo n.º 6
0
        public StatisticsModel ComputeStatistics()
        {
            var stats = new StatisticsModel();

            stats.PublicationsCount  = ItemsRepository.Publications.ToList().Count();
            stats.SubscriptionsCount = ItemsRepository.Subscriptions.ToList().Count();

            stats.PublicationsFinishedCount  = ItemsRepository.Publications.ToList().Where(p => p.Value.IsFinished).Count();
            stats.SubscriptionsFinishedCount = ItemsRepository.Subscriptions.ToList().Where(s => s.Value.IsFinished).Count();

            try
            {
                var avg = GetAverageTotalTime(ItemsRepository.Publications.Where(p => p.Value.IsFinished).Select(x => x.Value).ToList());
                var ts  = TimeSpan.FromTicks(Convert.ToInt64(avg)).TotalSeconds;
                stats.PublicationsAverageTotalTime = ts + " seconds";
                avg = GetAverageTotalTime(ItemsRepository.Subscriptions.Where(s => s.Value.IsFinished).Select(x => x.Value).ToList());
                ts  = TimeSpan.FromTicks(Convert.ToInt64(avg)).TotalSeconds;
                stats.SubscriptionsAverageTotalTime = ts + " seconds";
            }
            catch (Exception ex)
            {
                stats.PublicationsAverageTotalTime  = "unavailable";
                stats.SubscriptionsAverageTotalTime = "unabailable";
                Console.WriteLine("No worries m8 :)");
            }

            return(stats);
        }
Ejemplo n.º 7
0
        // GET: Admin/Stats
        public ActionResult Index()
        {
            StatisticsModel model = new StatisticsModel();

            model.TotalQuestions = _repository.GetQuestionCount();
            return(View(model));
        }
        public IActionResult ExerciseRecords(ExerciseRecordsChartViewModel model)
        {
            if (ModelState.IsValid)
            {
                var userId  = userManager.GetUserId(HttpContext.User);
                var dayFrom = DateTime.Now.ToLocalTime();
                var dayTo   = DateTime.Now.ToLocalTime();

                var userHeads     = GetUserHead(model);
                var userSpec      = GetUserSpec(userHeads);
                var userExercises = appContext.Exercises.OrderBy(x => x.Name);

                StatisticsModel statisticsModel = new StatisticsModel();

                List <Point <int, float> > exerciseRecordsRow = statisticsModel.GetExerciseRecords(
                    new UserGeneralData {
                    UserId = userId, DateFrom = dayFrom, DateTo = dayTo, UserSpecs = userSpec, UserHead = userHeads, UserExercises = userExercises
                });

                BarChart <int, float> barChart = new BarChart <int, float>(localizerStatisticController["TittleBarChart"], exerciseRecordsRow, localizerStatisticController);
                var jsonData  = chartProvider.GetBarChart(barChart);
                var viewModel = new ExerciseRecordsChartViewModel {
                    DayFrom = model.DayFrom, DayTo = model.DayTo, UserId = model.UserId, ChartDataJSON = jsonData
                };
                return(View(viewModel));
            }
            return(RedirectToAction(nameof(ExerciseRecords)));
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 获取代理洗码费抽水结算统计
 /// </summary>
 /// <param name="model"></param>
 /// <param name="head"></param>
 /// <param name="error"></param>
 /// <returns></returns>
 public string GetOddsWashF4Agent(StatisticsModel model, HeadMessage head, out ErrorMessage error)
 {
     error       = new ErrorMessage();
     error.ErrNo = "0004";
     try
     {
         string strSql = Common.SqlTemplateCommon.GetSql("GetACOdds4Agent");
         if (string.IsNullOrEmpty(strSql))
         {
             error.ErrMsg = "服务端没有读取到GetACOdds4Agent数据模板,请联系管理员";
             return(null);
         }
         if (string.IsNullOrEmpty(model.A_ID))
         {
             error.ErrMsg = "没有接收到请求参数";
             return(null);
         }
         strSql       = strSql.Replace("${AgentID}", model.A_ID);
         error.ErrMsg = "获取数据成功";
         error.ErrNo  = "0000";
         return(JSON.ToJSON(new
         {
             JsonData = Common.CommonHelper.DataTableToJson(Db.Context_SqlServer.FromSql(strSql).ToDataTable())
         }));
     }
     catch (Exception ex)
     {
         Common.LogHelper.WriteLog(typeof(AStatisticsDAL), ex);
         error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", "");
         return(null);
     }
 }
Ejemplo n.º 10
0
        public static StatisticsModel Count(List <ReportModel> reports)
        {
            var statistics = new StatisticsModel();

            foreach (var report in reports)
            {
                statistics.TotalCost += report.TotalPrice;
                statistics.Distance  += report.Distance;

                if (report.SecondaryFuel_ID != null)
                {
                    statistics.TotalCost += report.SecondaryFuelUnitPrice.Value;
                }
            }
            if (reports.Count > 0)
            {
                if (statistics.AvarageCost > 0)
                {
                    statistics.AvarageCost = statistics.TotalCost / reports.Count;
                }

                if (statistics.AvarageDistance > 0)
                {
                    statistics.AvarageDistance = statistics.Distance / reports.Count;
                }

                if (statistics.Distance > 0)
                {
                    statistics.AvarageFuelTenKm = statistics.TotalCost / statistics.Distance * 10;
                }
            }

            return(statistics);
        }
Ejemplo n.º 11
0
        public List <StatisticsModel> getLecturerCountByFaculty()
        {
            List <StatisticsModel> listLecturerCountByFaculty = new List <StatisticsModel>();

            try
            {
                string          Query = "SELECT Faculty,count(*) as Lecturers_Count FROM college_db.lecturersnew group by Faculty";
                MySqlConnection con   = new MySqlConnection(DBConnection.ConnectionString);

                MySqlCommand    cmd = new MySqlCommand(Query, con);
                MySqlDataReader myReader;
                con.Open();
                myReader = cmd.ExecuteReader();

                while (myReader.Read())
                {
                    StatisticsModel objLecturerCountByFaculty = new StatisticsModel();
                    objLecturerCountByFaculty.Faculty         = myReader["Faculty"].ToString();
                    objLecturerCountByFaculty.Lecturers_Count = Convert.ToInt32(myReader["Lecturers_Count"].ToString());
                    listLecturerCountByFaculty.Add(objLecturerCountByFaculty);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(listLecturerCountByFaculty);
        }
Ejemplo n.º 12
0
        public List <StatisticsModel> getStudentGroupCountByYear()
        {
            List <StatisticsModel> listStudentGroupCountByYear = new List <StatisticsModel>();

            try
            {
                string          Query = "SELECT Year, count(*) as Student_Count FROM college_db.group group by Year";
                MySqlConnection con   = new MySqlConnection(DBConnection.ConnectionString);

                MySqlCommand    cmd = new MySqlCommand(Query, con);
                MySqlDataReader myReader;
                con.Open();
                myReader = cmd.ExecuteReader();

                while (myReader.Read())
                {
                    StatisticsModel objStudentGroupCountByYear = new StatisticsModel();
                    objStudentGroupCountByYear.Year          = myReader["Year"].ToString();
                    objStudentGroupCountByYear.Student_Count = Convert.ToInt32(myReader["Student_Count"].ToString());
                    listStudentGroupCountByYear.Add(objStudentGroupCountByYear);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(listStudentGroupCountByYear);
        }
Ejemplo n.º 13
0
        public List <StatisticsModel> getProgrammesCount()
        {
            List <StatisticsModel> listProgrammesCount = new List <StatisticsModel>();

            try
            {
                string          Query = "Select * from college_db.programmes";
                MySqlConnection con   = new MySqlConnection(DBConnection.ConnectionString);

                MySqlCommand    cmd = new MySqlCommand(Query, con);
                MySqlDataReader myReader;
                con.Open();
                myReader = cmd.ExecuteReader();

                while (myReader.Read())
                {
                    StatisticsModel objProgrammes = new StatisticsModel();
                    objProgrammes.Programme_Year   = Convert.ToInt32(myReader["programme_year"].ToString());
                    objProgrammes.Total_Programmes = Convert.ToInt32(myReader["total_programmes"].ToString());
                    listProgrammesCount.Add(objProgrammes);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(listProgrammesCount);
        }
Ejemplo n.º 14
0
        internal StatisticsModel[] GetStatisticsForMonthAndYear(int month, int year)
        {
            using (ClothingStoreDBContext db = new ClothingStoreDBContext())
            {
                var repo = new ClothingStoreRepository(db);

                int daysInMonth;

                try
                {
                    daysInMonth = DateTime.DaysInMonth(year, month);
                }
                catch (ArgumentOutOfRangeException)
                {
                    throw new Exception("Year / Month Invalid");
                }

                var result = new StatisticsModel[daysInMonth];

                var purchasesInMonth = repo.GetPurchasesInMonthByMonthAndYear(month, year);
                var returnsInMonth   = repo.GetReturnsInMonthByMonthAndYear(month, year);

                for (var i = 0; i < daysInMonth; i++)
                {
                    result[i] = new StatisticsModel()
                    {
                        Day       = i + 1,
                        Purchases = (purchasesInMonth.ContainsKey(i + 1)) ? (int?)purchasesInMonth[i + 1] : null,
                        Returns   = (returnsInMonth.ContainsKey(i + 1)) ? (int?)returnsInMonth[i + 1] : null,
                    };
                }

                return(result);
            }
        }
Ejemplo n.º 15
0
        // GET: Statistics
        public ActionResult Statistics()
        {
            StatisticsModel m = new StatisticsModel();

            List <Uzenet>    messageItems   = messageRepository.GetAllMessage();
            List <Felszalla> busesOnTheRoad = messageRepository.GetAllBusOnRoad();

            var config = new MapperConfiguration(cfg => {
                cfg.CreateMap <Uzenet, MessageModel>()
                .ForMember(x => x.MessageId, x => x.MapFrom(y => y.uzenetId))
                .ForMember(x => x.DriverName, x => x.MapFrom(y => y.Sofor.soforNev))
                .ForMember(x => x.MessageTypeName, x => x.MapFrom(y => y.Jelze.jelzesNev))
                .ForMember(x => x.Line, x => x.MapFrom(y => y.Vonal.vonalId))
                .ForMember(x => x.Bus, x => x.MapFrom(y => y.Busz.buszId))
                .ForMember(x => x.MessageDate, x => x.MapFrom(y => y.datum))
                .ForMember(x => x.MessageLat, x => x.MapFrom(y => y.lon))
                .ForMember(x => x.MessageLon, x => x.MapFrom(y => y.lat));

                cfg.CreateMap <Felszalla, BusesOnTheRoadModel>()
                .ForMember(x => x.Id, x => x.MapFrom(y => y.felszallasId))
                .ForMember(x => x.Line, x => x.MapFrom(y => y.vonalId))
                .ForMember(x => x.lat, x => x.MapFrom(y => y.lat))
                .ForMember(x => x.lon, x => x.MapFrom(y => y.lon))
                .ForMember(x => x.Date, x => x.MapFrom(y => y.datum));
            });

            IMapper mapper = config.CreateMapper();

            m.Messages       = mapper.Map <ICollection <Uzenet>, List <MessageModel> >(messageItems);
            m.BusesOnTheRoad = mapper.Map <ICollection <Felszalla>, List <BusesOnTheRoadModel> >(busesOnTheRoad);

            return(View(m));;
        }
        public IActionResult ShowResults(int surveyId)
        {
            StatisticsModel model = new StatisticsModel();

            model.Survey            = surveyService.GetSurvey(surveyId);
            model.NumberOfResponses = statisticsService.GetNumerOfResponsesBySurvey(surveyId);

            model.Questions = questionService.GetQuestionsForSurvey(surveyId);

            model.QuestionStatistics = new List <QuestionStatistics>();
            foreach (var question in model.Questions)
            {
                QuestionStatistics questionStatistics = new QuestionStatistics();
                questionStatistics.Question             = question;
                questionStatistics.QuestionOptionModels = new List <QuestionOptionModel>();

                question.Options = questionService.GetOptionsForQuestion(question.QuestionId);

                foreach (var option in question.Options)
                {
                    QuestionOptionModel questionOptionModel = new QuestionOptionModel();
                    questionOptionModel.QuestionOption = option;
                    questionOptionModel.countQuestionOptionSelected = questionService.GetCountQuestionOptionSelectById(option.QuestionOptionId);
                    questionStatistics.QuestionOptionModels.Add(questionOptionModel);
                }

                model.QuestionStatistics.Add(questionStatistics);
            }

            return(View("Views/Statistics/Results.cshtml", model));
        }
Ejemplo n.º 17
0
        public IResult GetDashboard()
        {
            var result = new Result
            {
                Operation = Operation.Read,
                Status    = Status.Success
            };

            try
            {
                var statistics = new StatisticsModel();

                statistics.CategoryCount       = GetCategories().TotalCount;
                statistics.CategoryLastUpdated = _dashboardRepository.LastCategoryUpdated();
                statistics.CategoryResult      = GetCategories().CategoryResult;
                statistics.ProductCount        = GetProducts().TotalCount;
                statistics.ProductLastUpdated  = _dashboardRepository.LastProductUpdated();
                statistics.ProductResult       = GetProducts().ProductResult;

                result.Status     = Status.Success;
                result.StatusCode = HttpStatusCode.OK;
                result.Body       = statistics;
                return(result);
            }
            catch (Exception e)
            {
                result.Status     = Status.Error;
                result.Message    = e.Message;
                result.StatusCode = HttpStatusCode.InternalServerError;

                return(result);
            }
        }
Ejemplo n.º 18
0
        public async Task GetLibraryStatistics()
        {
            // Arrange

            var target = CreateTestTarget();

            // Act

            var statistics = await target.GetLibraryStatistics(CancellationToken.None);

            // Assert

            var expectedStatistics = new StatisticsModel
            {
                ArtistsNumber                  = 1,
                DiscArtistsNumber              = 1,
                DiscsNumber                    = 2,
                SongsNumber                    = 3,
                StorageSize                    = 1614431,
                SongsDuration                  = TimeSpan.FromMilliseconds(32844),
                PlaybacksDuration              = TimeSpan.FromMilliseconds(529191),
                PlaybacksNumber                = 5,
                UnheardSongsNumber             = 1,
                UnratedSongsNumber             = 1,
                NumberOfDiscsWithoutCoverImage = 1,
            };

            statistics.Should().BeEquivalentTo(expectedStatistics, x => x.WithStrictOrdering());
        }
Ejemplo n.º 19
0
        public Models(int numPipelines = 1)
        {
            NumPipelines = numPipelines;
            CheckDeviceCapabilities();

            SharedModel        = new SharedModel();
            Images             = new ImagesModel(SharedModel.ScaleShader);
            TextureCache       = new TextureCache(Images);
            pixelValueShader   = new PixelValueShader(SharedModel);
            polarConvertShader = new ConvertPolarShader(SharedModel.QuadShader);

            Export = new ExportModel(SharedModel);
            Filter = new FiltersModel(Images);
            //Gif = new GifModel(sharedModel.QuadShader);
            Progress = new ProgressModel();

            for (int i = 0; i < numPipelines; ++i)
            {
                pipelines.Add(new ImagePipeline(i));
                pipelines.Last().PropertyChanged += PipeOnPropertyChanged;
            }
            Pipelines = pipelines;

            stats     = new StatisticsModel(SharedModel);
            thumbnail = new ThumbnailModel(SharedModel.QuadShader);

            // pipeline controller
            pipelineController = new PipelineController(this);
        }
Ejemplo n.º 20
0
        // GET: ParkedVehicles/Statistics
        public async Task <IActionResult> Statistics()
        {
            var vehicles = await _context.ParkedVehicle.ToListAsync();

            var      nSM                = new StatisticsModel();
            DateTime longestParked      = DateTime.MaxValue;
            string   longestParkedRegNo = "";

            foreach (var vehicle in vehicles)
            {
                nSM.TotalAmountOfWheels += vehicle.WheelsNum;
                var price = (int)(DateTime.Now - vehicle.EnteringTime).TotalMinutes * 10 / 60;
                nSM.TotalRevenue += price;
                if (longestParked > vehicle.EnteringTime)
                {
                    longestParked      = vehicle.EnteringTime;
                    longestParkedRegNo = vehicle.RegistrationNum;
                }
                nSM.LongestParkedVehicleDate  = longestParked;
                nSM.LongestParkedVehicleRegNo = longestParkedRegNo;
                nSM.VehicleTypeCounter        = VehicleTypeCounter();
            }

            return(View(nSM));
        }
        public List <StatisticsModel> getLecturerCountByDepartment()
        {
            List <StatisticsModel> listLecturerCountByDepartment = new List <StatisticsModel>();

            try
            {
                string Query = "SELECT department,count(*) as Lecturers_Count FROM lecturers group by department";


                SqlCommand    cmd = new SqlCommand(Query, DBConnection.DatabaseConnection);
                SqlDataReader myReader;
                DBConnection.OpenConnection();
                myReader = cmd.ExecuteReader();

                while (myReader.Read())
                {
                    StatisticsModel objLecturerCountByDepartment = new StatisticsModel();
                    objLecturerCountByDepartment.Department      = myReader["department"].ToString();
                    objLecturerCountByDepartment.Lecturers_Count = Convert.ToInt32(myReader["Lecturers_Count"].ToString());
                    listLecturerCountByDepartment.Add(objLecturerCountByDepartment);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(listLecturerCountByDepartment);
        }
        //subject stats
        public List <StatisticsModel> getSubjectOfferedCountByYear()
        {
            List <StatisticsModel> listSubjectOfferedCountByYear = new List <StatisticsModel>();

            try
            {
                string Query = "SELECT year,count(*) as Offered_Subject_Count FROM subjects group by year";


                SqlCommand    cmd = new SqlCommand(Query, DBConnection.DatabaseConnection);
                SqlDataReader myReader;
                DBConnection.OpenConnection();
                myReader = cmd.ExecuteReader();

                while (myReader.Read())
                {
                    StatisticsModel objSubjectOfferedCountByYear = new StatisticsModel();
                    objSubjectOfferedCountByYear.Offered_Year          = myReader["year"].ToString();
                    objSubjectOfferedCountByYear.Offered_Subject_Count = Convert.ToInt32(myReader["Offered_Subject_Count"].ToString());
                    listSubjectOfferedCountByYear.Add(objSubjectOfferedCountByYear);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(listSubjectOfferedCountByYear);
        }
        public List <StatisticsModel> getStudentGroupCountByProgram()
        {
            List <StatisticsModel> listStudentGroupCountByProgram = new List <StatisticsModel>();

            try
            {
                string Query = " SELECT program, count(*) as Student_Count FROM groups group by program";


                SqlCommand    cmd = new SqlCommand(Query, DBConnection.DatabaseConnection);
                SqlDataReader myReader;
                DBConnection.OpenConnection();
                myReader = cmd.ExecuteReader();

                while (myReader.Read())
                {
                    StatisticsModel objStudentGroupCountByProgram = new StatisticsModel();
                    objStudentGroupCountByProgram.Program       = myReader["program"].ToString();
                    objStudentGroupCountByProgram.Student_Count = Convert.ToInt32(myReader["Student_Count"].ToString());
                    listStudentGroupCountByProgram.Add(objStudentGroupCountByProgram);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(listStudentGroupCountByProgram);
        }
Ejemplo n.º 24
0
        public MainWindow()
        {
            InitializeComponent();
            setup      = new SetupModel();
            monitor    = new MonitorModel();
            statistics = new StatisticsModel();

            listItems = new List <menuItem>();
            listItems.Add(new menuItem()
            {
                enabled = true, text = "Border Setup"
            });
            listItems.Add(new menuItem()
            {
                enabled = false, text = "Room Monitor"
            });
            listItems.Add(new menuItem()
            {
                enabled = false, text = "Statistics"
            });
            listItems.Add(new menuItem()
            {
                enabled = true, text = "Quit App"
            });


            lbMenu.ItemsSource = listItems;
        }
        public List <StatisticsModel> getProgrammesCount()
        {
            List <StatisticsModel> listProgrammesCount = new List <StatisticsModel>();

            try
            {
                string Query = "Select * from program group by name";


                SqlCommand    cmd = new SqlCommand(Query, DBConnection.DatabaseConnection);
                SqlDataReader myReader;
                DBConnection.OpenConnection();
                myReader = cmd.ExecuteReader();

                while (myReader.Read())
                {
                    StatisticsModel objProgrammes = new StatisticsModel();
                    objProgrammes.Programme_Year   = Convert.ToInt32(myReader["name"].ToString());
                    objProgrammes.Total_Programmes = Convert.ToInt32(myReader["total_programmes"].ToString());
                    listProgrammesCount.Add(objProgrammes);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(listProgrammesCount);
        }
Ejemplo n.º 26
0
        public void LogStats(int stashes)
        {
            var avgGet          = _requestTimes.Count > 0 ? Math.Round(_requestTimes.Average()) : 0;
            var avgDeszerialize = _deseralizeTimes.Count > 0 ? Math.Round(_deseralizeTimes.Average()) : 0;
            var avgUpdate       = _updateTimes.Count > 0 ? Math.Round(_updateTimes.Average()) : 0;

            var statistics = new StatisticsModel()
            {
                ChangeId              = _nextChangeId,
                AvgGET                = avgGet,
                AvgDeserialize        = avgDeszerialize,
                AvgUpdateRedis        = avgUpdate,
                StashesInLastResponse = stashes,
                RateLimitedOrDown     = _rateLimited,
                Timestamp             = DateTime.Now
            };

            _cache.Set <StatisticsModel>("Statistics", statistics);

            _log.LogWarning($"" +
                            $"AvgGET: {avgGet}ms, " +
                            $"AvgDeserialize: {avgDeszerialize}ms, " +
                            $"AvgUpdate: { avgUpdate}ms, " +
                            $"StashesInLastResponse: {stashes}, " +
                            $"RateLimited: {_rateLimited}");
        }
Ejemplo n.º 27
0
        public async Task <ViewResult> Index()
        {
            try
            {
                var userRole = await _repo.IsRoleByName(RolesEnum.User.ToString());

                var users = (await _repo.FindUsers(userRole.Id)).Where(u => u.PhoneNumberConfirmed).ToList();


                var agentsRole = await _repo.IsRoleByName(RolesEnum.Agent.ToString());

                var agents = (await _repo.FindUsers(agentsRole.Id)).Where(u => u.PhoneNumberConfirmed).ToList();

                var requests = _UnitOfWork.RequestRepository.Filter(x => x.Type == RequestTypeEnum.Request);
                var trips    = _UnitOfWork.RequestRepository.Filter(x => x.Type == RequestTypeEnum.Trip);


                var cities = _UnitOfWork.CityRepository.Count;

                var paths = _UnitOfWork.PathRepository.All();


                var role = await _repo.IsRoleByName(RolesEnum.Agent.ToString());

                var agentRequests = await _repo.FindNewAgentsByRoleId(role.Id);

                int agentRequestsCount = agentRequests.Count();

                int agentRequestsUnSeenCount = agentRequests.Count(u => !u.RequestIsSeen);

                var model = new StatisticsModel()
                {
                    UserCount  = users.Count,
                    AgentCount = agents.Count,

                    RequestNew        = requests.Count(u => u.Status == RequestStatusEnum.New),
                    RequestInProgress = requests.Count(u => u.Status == RequestStatusEnum.Inprogress),
                    RequestCanceled   = requests.Count(u => u.Status == RequestStatusEnum.Canceled),
                    RequestDelivered  = requests.Count(u => u.Status == RequestStatusEnum.Delivered),

                    TripNew        = trips.Count(u => u.Status == RequestStatusEnum.New),
                    TripInProgress = trips.Count(u => u.Status == RequestStatusEnum.Inprogress),
                    TripCanceled   = trips.Count(u => u.Status == RequestStatusEnum.Canceled),
                    TripDelivered  = trips.Count(u => u.Status == RequestStatusEnum.Delivered),

                    InternalPath             = paths.Count(u => u.Type == PathTypesEnum.Internal),
                    ExternalPath             = paths.Count(u => u.Type == PathTypesEnum.External),
                    AgentRequestsCount       = agentRequestsCount,
                    AgentRequestsUnSeenCount = agentRequestsUnSeenCount,
                    CityCount = cities

                                //TripCount = trips.Count(),
                };
                return(View(model));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
        public StatisticsModel GetStatistics(String payment_method)
        {
            string          sql    = null;
            StatisticsModel result = new StatisticsModel();

            if (payment_method != null)
            {
                sql = "WHERE payment_method = '" + payment_method + "' ";
            }

            List <SaleModel> Sales = db.SelectOrderList(sql);

            foreach (SaleModel Sale in Sales)
            {
                float Originalprice = Sale.price;
                float SalePercent   = (float)Sale.sale / 100;
                float PureSalePrice = Originalprice * (1 - SalePercent);
                float SalePrice     = Originalprice * SalePercent;

                result.OriginalPrice += (int)Originalprice * Sale.count;
                result.SalePrice     += (int)SalePrice * Sale.count;
                result.PureSalePrice += (int)PureSalePrice * Sale.count;
            }

            Console.WriteLine(result.OriginalPrice);

            return(result);
        }
Ejemplo n.º 29
0
        public ActionResult <IEnumerable <StatisticsModel> > GetDeliveriesForStatisticsOfDispatcher(string d11, string d22)
        {
            DateTime d1 = new DateTime(Convert.ToInt64(d11));
            DateTime d2 = new DateTime(Convert.ToInt64(d22));

            try
            {
                List <StatisticsModel> list = new List <StatisticsModel>();
                var users = userRepository.GetUsersIdsWithDispatcherRole();
                foreach (var item in users)
                {
                    StatisticsModel sm = new StatisticsModel {
                        UserID = item
                    };
                    var deliveries = deliveryRepository.GetAllDeliveries().Where(x => (x.DeliveryStatus == 4) && (x.DispatcherID == item) && (x.CreateTime.Date >= d1.Date) && (x.CreateTime.Date <= d2.Date));

                    foreach (var delivery in deliveries)
                    {
                        sm.Promet += Convert.ToDouble(delivery.DeliveryPrice);
                        switch (delivery.PaymentTypeID)
                        {
                        //kes
                        case 1:
                            sm.PrometCash += delivery.DeliveryPrice;
                            break;

                        //faktura odnosno preko racuna
                        case 2:
                            sm.PrometFaktura += delivery.DeliveryPrice;
                            break;

                        //kupon
                        case 3:
                            sm.PrometCupon += delivery.DeliveryPrice;
                            break;

                        default:
                            break;
                        }
                    }
                    sm.BrojDostava     = deliveries.Count();
                    sm.PrihodOdPrometa = sm.BrojDostava * 25;
                    list.Add(sm);
                }

                if (list != null)
                {
                    return(Ok(list));
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model">
        /// </param>
        /// <exception cref="ArgumentException">
        /// </exception>
        public StatisticsViewModel(StatisticsModel model)
        {
            m_model = model;

            if (m_model == null)
            {
                throw new ArgumentException("Expected valid StatisticsModel instance.");
            }
        }
        public ActionResult GetStatistics()
        {
            var newStats = this.statisticService
                .GetYearlyStatistics(DateTime.Now.Year, this.User.Identity.Name);
            var oldStats = this.statisticService
                .GetYearlyStatistics(DateTime.Now.Year - 1, this.User.Identity.Name);

            var model = new StatisticsModel
            {
                NewStats = newStats,
                OldStats = oldStats,
                MaxUserVisits = 100
            };

            return this.View(model);
        }