public async Task PostScore()
        {
            try
            {
                if (!IsBusy)
                {
                    var addScoreService = new AddScoreService();
                    var requestModel    = new AddScoreRequestModel {
                        Name = UserTag, Score = AverageTime.ToString(), Difficuilty = Preferences.Get("difficulty", Difficulty.Easy.ToString())
                    };
                    var response = await addScoreService.AddScore(requestModel);

                    if (response.Status != null)
                    {
                        if (response.Rank != 0)
                        {
                            ShowText        = "You are now ranked ";
                            ShowAverageTime = "NO." + response.Rank;
                        }
                        CheckNumberOfVisit();
                    }
                }
            }
            catch (Exception ex)
            {
                IsBusy          = false;
                ShowText        = "Play again to sharpen your brain";
                ShowAverageTime = "";
                Crashes.TrackError(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #2
0
 private void Start()
 {
     if (AverageTime != null)
     {
         AverageTime.Invoke();
     }
     if (PlayedGames != null)
     {
         PlayedGames.Invoke();
     }
     if (AverageScore != null)
     {
         AverageScore.Invoke();
     }
 }
        void Process()
        {
            try
            {
                var averageFuelPerLap = AverageFuelUsage.Capture(avg => AverageFuelPerLap = avg);
                var onEachLap         = OnEachLap.Capture(averageFuelPerLap);

                var averageLapTime   = AverageTime.Capture(avg => AverageLapTimeSpan = avg);
                var onEachSessionLap = OnEachSessionLap.Capture(averageLapTime);
                var onEachSession    = OnEachSessionUpdate.Capture(onEachSessionLap);

                var data      = CaptureLatestData(EmitTo.All(onEachLap, onEachSession));
                var connected = ConnectedDataOnly(data);

                iracing.GetDataFeed().EmitTo(StopOnRequestCancel(connected));
            }
            catch (Exception e)
            {
                Trace.WriteLine("Non Recoverable error in DataCollector. {0}".F(e.Message), "INFO");
                Trace.WriteLine(e.StackTrace, "DEBUG");
            }
        }
Exemple #4
0
        public ReportTemplateWrapper SaveReportTemplate(
            string name,
            string period,
            int periodItem,
            int hour,
            bool autoGenerated,
            ReportType reportType,
            int tag,
            int project,
            TaskStatus?status,
            Guid departament,
            Guid userId,
            ReportTimeInterval reportTimeInterval,
            ApiDateTime fromDate,
            ApiDateTime toDate,
            int viewType,
            bool noResponsible,
            bool isShowAverageTime,
            AverageTime typeOfShowAverageTime,
            bool projectAverageCompletingTasks
            )
        {
            ProjectSecurity.DemandAuthentication();

            if (name == null || name.Trim().Length == 0)
            {
                throw new ArgumentNullException("name");
            }

            var filter = new TaskFilter
            {
                TagId                 = tag,
                DepartmentId          = departament,
                UserId                = userId,
                TimeInterval          = reportTimeInterval,
                FromDate              = fromDate,
                ToDate                = toDate,
                ViewType              = viewType,
                NoResponsible         = noResponsible,
                IsShowAverageTime     = isShowAverageTime,
                TypeOfShowAverageTime = typeOfShowAverageTime
            };

            if (projectAverageCompletingTasks)
            {
                filter.IsShowAverageTime     = true;
                filter.TypeOfShowAverageTime = AverageTime.CompletingTasks;
            }

            if (project != 0)
            {
                filter.ProjectIds.Add(project);
            }

            if (status != null)
            {
                filter.TaskStatuses.Add((TaskStatus)status);
            }

            var template = new ReportTemplate(reportType)
            {
                Filter = filter
            };

            SaveOrUpdateTemplate(template, name, period, periodItem, hour, autoGenerated);
            MessageService.Send(Request, MessageAction.ReportTemplateCreated, MessageTarget.Create(template.Id), template.Name);

            return(new ReportTemplateWrapper(template));
        }
Exemple #5
0
 /// <summary>
 /// 定时器
 /// </summary>
 /// <param name="averageTime"></param>
 /// <param name="offset"></param>
 public Timer(AverageTime averageTime, int offset = 0)
 {
     _minutes = (int)averageTime;
     _offset  = offset;
 }
        private void AddStatistics(AnalyticsLevel level, string path, Method[] methods)
        {
            var baseId = path + "+";

            if (methods != null && methods.Length > 0)
            {
                baseId = string.Join("", methods) + baseId + "+";
            }

            if (!string.IsNullOrEmpty(_userSegmentKey))
            {
                baseId += _userSegmentKey + "+";
            }

            var name = path;

            if (methods != null && methods.Length > 0)
            {
                name = string.Join(" or ", methods) + " " + name;
            }

            if (!string.IsNullOrEmpty(_userSegmentKey))
            {
                name += " for '" + _userSegmentKey + "' users";
            }

            if (level == AnalyticsLevel.Basic || level == AnalyticsLevel.Full)
            {
                _availableStatistics.Add(
                    new StatisticInformation
                {
                    Id          = baseId + "RequestCount",
                    Name        = "Requests to " + name,
                    Description = "The total number of requests to " + name + " since the service was started"
                });
                _availableStatistics.Add(
                    new StatisticInformation
                {
                    Id          = baseId + "FailCount",
                    Name        = "Failed requests to " + name,
                    Description = "The number of requests to " + name + " that failed since the service was started"
                });
            }
            if (level == AnalyticsLevel.Full)
            {
                _requestsPerMinute = new CountPerMinute();
                _availableStatistics.Add(
                    new StatisticInformation
                {
                    Id          = baseId + "RequestRate",
                    Name        = "Requests per minute to " + name,
                    Description = "The number of successful requests per minute made to " + name + " over the last 10 minutes"
                });
            }
            if (level == AnalyticsLevel.Full)
            {
                _millisecondsPerRequest = new AverageTime();
                _availableStatistics.Add(
                    new StatisticInformation
                {
                    Id          = baseId + "RequestTime",
                    Name        = "Average execution time for " + name,
                    Description = "The average time taken to execute successful requests to " + name + " in the last 10 minutes"
                });
            }
        }