public object Post(LogApplicationStartUpRequest request)
        {
            var session = this.GetSession();
            var account = _dao.FindById(new Guid(session.UserAuthId));

            var command = new LogApplicationStartUp
            {
                UserId             = account.Id,
                Email              = account.Email,
                DateOccured        = request.StartUpDate,
                ApplicationVersion = request.ApplicationVersion,
                Platform           = request.Platform,
                PlatformDetails    = request.PlatformDetails,
                ServerVersion      = Assembly.GetAssembly(typeof(ApplicationInfoService)).GetName().Version.ToString(),
                Latitude           = request.Latitude,
                Longitude          = request.Longitude
            };

            _commandBus.Send(command);

            return(new HttpResult(HttpStatusCode.OK));
        }
Пример #2
0
        public async void LogApplicationStartUp()
        {
            try
            {
                var packageInfo = Mvx.Resolve <IPackageInfo>();

                var position = await _locationService.GetUserPosition();

                var request = new LogApplicationStartUpRequest
                {
                    StartUpDate        = DateTime.UtcNow,
                    Platform           = packageInfo.Platform,
                    PlatformDetails    = packageInfo.PlatformDetails,
                    ApplicationVersion = packageInfo.Version,
                    Latitude           = position != null
                        ? position.Latitude
                        : 0,
                    Longitude = position != null
                        ? position.Longitude
                        : 0
                };

                //This needs to be awaited to catch exceptions and must be the last task to be awaited before the end of this try catch block.
                await UseServiceClientAsync <MetricsServiceClient>(
                    client => client.LogApplicationStartUp(request),
                    exception =>
                {
                    // rethrow the exception, we don't need to use the HandleError process.
                    throw exception;
                });
            }
            catch (Exception ex)
            {
                // If logging fails, run app anyway and log exception
                Logger.LogError(ex);
            }
        }
Пример #3
0
 public Task LogApplicationStartUp(LogApplicationStartUpRequest request)
 {
     return(Client.PostAsync <string>("/account/logstartup", request, logger: Logger));
 }