public void SaveLocationLog(LocationLog LocationLog)
        {
            if (LocationLog.Id == 0)
            {
                context.LocationLogs.Add(LocationLog);
            }
            else
            {
                var editMe = context.LocationLogs.Find(LocationLog.Id);
                if (editMe != null)
                {
                    // dbEntry.Name = LocationLog.Name;
                    // dbEntry.Message = LocationLog.Message;
                    // dbEntry.TimeStamp = LocationLog.TimeStamp;
                }
            }

            try
            {
                context.SaveChanges();
            }
            catch (OptimisticConcurrencyException)
            {
                //context.(RefreshMode.ClientWins, dbModels.Models.LocationLog);
                //context.SaveChanges();
            }

            // context.SaveChanges();
        }
Ejemplo n.º 2
0
        public APIResponse Put(int id, [FromBody] LocationLog model)
        {
            APIResponse response = new APIResponse();

            if (model == null || model.ID != id)
            {
                response.Error = 1;
                return(response);
            }

            var item = _context.LocationLog.FirstOrDefault(m => m.ID == id);

            if (item == null)
            {
                response.Error = 2;
                return(response);
            }

            item.TerminalID = model.TerminalID;
            item.GDLocation = model.GDLocation;
            item.BDLocation = model.BDLocation;
            item.Latitude   = model.Latitude;
            item.Longitude  = model.Longitude;
            item.StationID  = model.StationID;



            _context.LocationLog.Update(item);
            _context.SaveChanges();
            return(response);
        }
        public async Task <ActionResult <LocationLog_LocationLogDTO> > Update([FromBody] LocationLog_LocationLogDTO LocationLog_LocationLogDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(LocationLog_LocationLogDTO.Id))
            {
                return(Forbid());
            }

            LocationLog LocationLog = ConvertDTOToEntity(LocationLog_LocationLogDTO);

            LocationLog = await LocationLogService.Update(LocationLog);

            LocationLog_LocationLogDTO = new LocationLog_LocationLogDTO(LocationLog);
            if (LocationLog.IsValidated)
            {
                return(LocationLog_LocationLogDTO);
            }
            else
            {
                return(BadRequest(LocationLog_LocationLogDTO));
            }
        }
Ejemplo n.º 4
0
        private static async Task <IActionResult> ExecuteLaunchRequestAsync(CEKRequest request, CloudTable locationLogs, AppConfiguration config)
        {
            var response           = new CEKResponse();
            var taskForSettings    = MessagingChatSettings.GetSettingsByUserIdAsync(locationLogs, request.Session.User.UserId);
            var taskForLocationLog = LocationLog.GetLocationLogByUserIdAsync(locationLogs, request.Session.User.UserId);
            await Task.WhenAll(taskForSettings, taskForLocationLog);

            var settings = taskForSettings.Result ?? new MessagingChatSettings {
                RowKey = request.Session.User.UserId
            };
            var locationLog = taskForLocationLog.Result;

            try
            {
                if (!settings.IsLineFrend)
                {
                    response.AddText(ClovaMessages.GetAddingLineFrendMessage());
                    return(new OkObjectResult(response));
                }

                AddHistory(settings);
                response.AddText(ClovaMessages.GetGuideMessage(settings.YourName));
                if (locationLog == null || !DateTimeOffsetUtils.IsToday(locationLog.Timestamp))
                {
                    // データが無い
                    response.AddText(ClovaMessages.GetNoLogMessage(settings.YourName));
                    await AskCurrentLocationAsync(request, config, settings);

                    return(new OkObjectResult(response));
                }

                if (DateTimeOffsetUtils.IsBefore(locationLog.Timestamp, TimeSpan.Parse(config.Cek.IsBeforeThreshold ?? Clova.IsBeforeThresholdDefaultValue)))
                {
                    // 古いデータ
                    response.AddText(ClovaMessages.GetOldLocationMessage(settings.YourName, locationLog));
                    await AskCurrentLocationAsync(request, config, settings);

                    return(new OkObjectResult(response));
                }

                // データがある
                response.AddText(ClovaMessages.GetLocationMessage(settings.YourName, locationLog));
                if (!string.IsNullOrEmpty(locationLog.Comment))
                {
                    response.AddText(ClovaMessages.GetCommentMessage(settings.YourName, locationLog));
                }
                else if (!string.IsNullOrEmpty(locationLog.AudioCommentUrl))
                {
                    response.AddText(ClovaMessages.GetVoiceMessagePrefixMessage(settings.YourName));
                    response.AddUrl(locationLog.AudioCommentUrl);
                }

                return(new OkObjectResult(response));
            }
            finally
            {
                await locationLogs.ExecuteAsync(TableOperation.InsertOrReplace(settings));
            }
        }
Ejemplo n.º 5
0
 public override void OnLocationAvailability(LocationAvailability locationAvailability)
 {
     if (locationAvailability != null)
     {
         bool flag = locationAvailability.IsLocationAvailable;
         LocationLog.Info(TAG, "onLocationAvailability isLocationAvailable:" + flag);
     }
 }
Ejemplo n.º 6
0
 public async Task <bool> ValidateUser(LocationLog LocationLog)
 {
     if (LocationLog.AppUserId != CurrentContext.UserId)
     {
         LocationLog.AddError(nameof(LocationLogValidator), nameof(LocationLog.Id), ErrorCode.NotCurrentUser);
     }
     return(LocationLog.AppUserId == CurrentContext.UserId);
 }
        public async Task <bool> Delete(LocationLog LocationLog)
        {
            await DataContext.LocationLog.Where(x => x.Id == LocationLog.Id).UpdateFromQueryAsync(x => new LocationLogDAO {
                DeletedAt = StaticParams.DateTimeNow, UpdatedAt = StaticParams.DateTimeNow
            });

            return(true);
        }
Ejemplo n.º 8
0
        public static string GetCommentMessage(string name, LocationLog locationLog)
        {
            if (string.IsNullOrEmpty(locationLog.Comment))
            {
                return("");
            }

            return($"また、{name}から、メッセージをもらっています。  {locationLog.Comment}");
        }
        public async Task <LocationLog> Get(long Id)
        {
            LocationLog LocationLog = await UOW.LocationLogRepository.Get(Id);

            if (LocationLog == null)
            {
                return(null);
            }
            return(LocationLog);
        }
Ejemplo n.º 10
0
        public static void AddLocationLog(string dbLocationName, string message, int concealmentLevel)
        {
            ILocationLogRepository LocationLogRepo = new EFLocationLogRepository();
            var newlog = new LocationLog();

            newlog.dbLocationName   = dbLocationName;
            newlog.Message          = message;
            newlog.Timestamp        = DateTime.UtcNow;
            newlog.ConcealmentLevel = concealmentLevel;
            LocationLogRepo.SaveLocationLog(newlog);
        }
Ejemplo n.º 11
0
        public async Task <int> OnLocationView(LocationResult location)
        {
            var logItem = new LocationLog {
                Title  = location.Title,
                WoeId  = location.WoeId,
                Viewed = DateTime.Now
            };

            _db.Add(logItem);
            return(await _db.SaveChangesAsync());
        }
Ejemplo n.º 12
0
 public AppUser_LocationLogDTO(LocationLog LocationLog)
 {
     this.Id             = LocationLog.Id;
     this.PreviousId     = LocationLog.PreviousId;
     this.AppUserId      = LocationLog.AppUserId;
     this.Latitude       = LocationLog.Latitude;
     this.Longtitude     = LocationLog.Longtitude;
     this.UpdateInterval = LocationLog.UpdateInterval;
     this.Previous       = LocationLog.Previous == null ? null : new AppUser_LocationLogDTO(LocationLog.Previous);
     this.Errors         = LocationLog.Errors;
 }
Ejemplo n.º 13
0
        public Log(string fileName, LocationLog locationLog = LocationLog.LogFolder, TimeStampType timestampType = TimeStampType.JustTime, FileNameSuffixLog suffixLog = FileNameSuffixLog.Date, int maxLogs = 10)
        {
            TimeStampType  = timestampType;
            LocationLog    = locationLog;
            FileNameSuffix = suffixLog;
            _maxLogs       = maxLogs;

            if (!string.IsNullOrEmpty(Path.GetDirectoryName(fileName)))
            {
                LocationLog = LocationLog.Custom;
                _folder     = Path.GetDirectoryName(fileName);
                _filename   = Path.GetFileNameWithoutExtension(fileName);
            }
            else
            {
                _filename = Path.GetFileNameWithoutExtension(fileName);
                switch (locationLog)
                {
                case LocationLog.Custom:
                case LocationLog.SameFolder:
                    _folder = ".";
                    break;

                case LocationLog.LogFolder:
                    _folder = "./log";
                    break;

                case LocationLog.ProgramDataFolder:
                    _folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), _vendor, _system);
                    break;
                }
                _folder = Path.GetFullPath(_folder);
            }
            LastException = "";
            if (!Directory.Exists(_folder))
            {
                try
                {
                    Directory.CreateDirectory(_folder);
                }
                catch (Exception e)
                {
                    LastException = e.Message;
                    throw new LogException("Erro ao criar diretório " + _folder, e);
                }
                if (!Directory.Exists(_folder))
                {
                    throw new LogException("Diretório " + _folder + " não foi encontrado");
                }
            }
        }
Ejemplo n.º 14
0
 private void RemoveLocationUpdatesWithCallback()
 {
     try
     {
         Task voidTask = mFusedLocationProviderClient.RemoveLocationUpdates(mLocationCallback);
         voidTask
         .AddOnSuccessListener(new RemoveLocCallUpdateOnSuccessListener())
         .AddOnFailureListener(new RemoveLocCallUpdateOnFailureListener());
     }
     catch (Exception e)
     {
         LocationLog.Error(TAG, "removeLocatonUpdatesWithCallback exception:" + e.Message);
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Registers the location.
 /// </summary>
 /// <param name="logItem">The log item.</param>
 /// <returns>LocationLog.</returns>
 public LocationLog RegisterLocation(LocationLog logItem)
 {
     try
     {
         var poi = GetPointOfInterest(logItem.PoIId);
         return(Provider <LocationLog> .Save(logItem));
     }
     catch (Exception exception)
     {
         logItem.AddError(exception.Message);
         _logger.Error(exception.GetCombinedMessages());
         return(logItem);
     }
 }
Ejemplo n.º 16
0
 public LocationLog_LocationLogDTO(LocationLog LocationLog)
 {
     this.Id             = LocationLog.Id;
     this.PreviousId     = LocationLog.PreviousId;
     this.AppUserId      = LocationLog.AppUserId;
     this.Latitude       = LocationLog.Latitude;
     this.Longtitude     = LocationLog.Longtitude;
     this.UpdateInterval = LocationLog.UpdateInterval;
     this.AppUser        = LocationLog.AppUser == null ? null : new LocationLog_AppUserDTO(LocationLog.AppUser);
     this.Previous       = LocationLog.Previous == null ? null : new LocationLog_LocationLogDTO(LocationLog.Previous);
     this.CreatedAt      = LocationLog.CreatedAt;
     this.UpdatedAt      = LocationLog.UpdatedAt;
     this.Errors         = LocationLog.Errors;
 }
Ejemplo n.º 17
0
        private async Task InputCommentAsync(ContextState contextState, MessageEvent ev)
        {
            if (ev.Message.Type == EventMessageType.Text)
            {
                var locationLog = await LocationLog.GetLocationLogByUserIdAsync(contextState.StateStoreTable, ev.Source.UserId);

                if (locationLog == null)
                {
                    await ReplyUnknownMessageAsync(contextState, ev);

                    return;
                }

                locationLog.Comment = ((TextEventMessage)ev.Message).Text;
                await LocationLog.InsertOrReplaceAsync(contextState.StateStoreTable, locationLog);
                await FinishInputAsync(contextState, ev, locationLog);

                SetNextCallMethod(nameof(InitializeAsync));
            }
            else if (ev.Message.Type == EventMessageType.Audio)
            {
                var locationLog = await LocationLog.GetLocationLogByUserIdAsync(contextState.StateStoreTable, ev.Source.UserId);

                if (locationLog == null)
                {
                    await ReplyUnknownMessageAsync(contextState, ev);

                    return;
                }

                using (var audio = await contextState.Client.GetContentStreamAsync(ev.Message.Id))
                {
                    var blob = await contextState.Binder.BindAsync <CloudBlockBlob>(new BlobAttribute($"files/{ev.Source.UserId}/{ev.Message.Id}{GetFileExtension(audio.ContentHeaders.ContentType.MediaType)}", FileAccess.Write));

                    await blob.UploadFromStreamAsync(audio);

                    locationLog.AudioCommentUrl = blob.Uri.ToString();
                }

                await LocationLog.InsertOrReplaceAsync(contextState.StateStoreTable, locationLog);
                await FinishInputAsync(contextState, ev, locationLog);

                SetNextCallMethod(nameof(InitializeAsync));
            }
            else
            {
                await ReplyUnknownMessageAsync(contextState, ev);
            }
        }
Ejemplo n.º 18
0
        public override void Execute(IDataContext context)
        {
            ContextQuery = ctx =>
            {
                var player = ctx.AsQueryable <Player>()
                             .Include(p => p.User)
                             .Include(i => i.PlayerLogs)
                             .SingleOrDefault(p => p.User.Id == UserId);

                if (player == null)
                {
                    throw new DomainException($"Player with user ID '{UserId}' could not be found");
                }

                if (player.Mobility != PvPStatics.MobilityFull)
                {
                    throw new DomainException("You must be animate in order to shout!");
                }

                if (player.ShoutsRemaining <= 0)
                {
                    throw new DomainException("You can only shout once per turn.");
                }

                var hushed = ctx.AsQueryable <Effect>()
                             .Where(e => e.EffectSource.Id == CharacterPrankProcedures.HUSHED_EFFECT &&
                                    e.Owner.Id == player.Id &&
                                    e.Duration > 0)
                             .Any();

                if (hushed)
                {
                    throw new DomainException("You have been hushed and cannot currently shout.");
                }


                Message = Message.Replace("<", "&lt;").Replace(">", "&gt;"); // remove suspicious characters

                var log = LocationLog.Create(player.Location, $"<span class='playerShoutNotification'>{player.GetFullName()} shouted <b>\"{Message}\"</b> here.</span>");

                player.Shout(Message);
                ctx.Update(player);
                ctx.Add(log);

                ctx.Commit();
            };

            ExecuteInternal(context);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Registers the location.
        /// </summary>
        /// <param name="logItem">The log item.</param>
        /// <returns>LocationLog.</returns>
        public LocationLog RegisterLocation(LocationLog logItem)
        {
            var clt = CreateClient();

            try
            {
                return(clt
                       .RegisterLocation(logItem.Zip())
                       .Unzip <LocationLog>());
            }
            finally
            {
                CloseClient(clt);
            }
        }
Ejemplo n.º 20
0
        public APIResponse Post([FromBody] LocationLog model)
        {
            APIResponse response = new APIResponse();

            if (model == null)
            {
                response.Error = 1;
                return(response);
            }
            //model.SamplingTime = (long)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds;

            _context.LocationLog.Add(model);
            _context.SaveChanges();
            return(response);
        }
Ejemplo n.º 21
0
        private async Task FinishInputAsync(ContextState contextState, MessageEvent ev, LocationLog locationLog = null)
        {
            locationLog = locationLog ?? await LocationLog.GetLocationLogByUserIdAsync(contextState.StateStoreTable, ev.Source.UserId);

            if (locationLog == null)
            {
                await ReplyUnknownMessageAsync(contextState, ev);

                return;
            }

            await contextState.Client.ReplyMessageAsync(ev.ReplyToken, LineMessages.GetFinishInputMessage(contextState.Settings, locationLog));

            SetNextCallMethod(nameof(InitializeAsync));
        }
        public async Task <ActionResult <LocationLog_LocationLogDTO> > Get([FromBody] LocationLog_LocationLogDTO LocationLog_LocationLogDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(LocationLog_LocationLogDTO.Id))
            {
                return(Forbid());
            }

            LocationLog LocationLog = await LocationLogService.Get(LocationLog_LocationLogDTO.Id);

            return(new LocationLog_LocationLogDTO(LocationLog));
        }
Ejemplo n.º 23
0
 public override void OnLocationResult(LocationResult locationResult)
 {
     if (locationResult != null)
     {
         IList <Android.Locations.Location> locations = locationResult.Locations;
         if (locations.Count != 0)
         {
             foreach (Android.Locations.Location location in locations)
             {
                 LocationLog.Info(TAG,
                                  "onLocationResult location[Longitude,Latitude,Accuracy]:" + location.Longitude
                                  + "," + location.Latitude + "," + location.Accuracy);
             }
         }
     }
 }
Ejemplo n.º 24
0
        private async Task ExecuteLocationMessageAsync(ContextState contextState, MessageEvent messageEvent)
        {
            var locationMessage = (LocationEventMessage)messageEvent.Message;
            var locationLog     = new LocationLog
            {
                RowKey    = messageEvent.Source.UserId,
                Latitude  = locationMessage.Latitude,
                Longitude = locationMessage.Longitude,
                Name      = locationMessage.Title,
                Address   = locationMessage.Address,
            };

            await contextState.StateStoreTable.ExecuteAsync(TableOperation.InsertOrReplace(locationLog));

            await contextState.Client.ReplyMessageAsync(messageEvent.ReplyToken, LineMessages.GetConfirmMessage(LineMessages.AskCommentMessage));

            SetNextCallMethod(nameof(AskingInputCommentAsync));
        }
Ejemplo n.º 25
0
 private void RequestLocationUpdatesWithCallback()
 {
     try
     {
         LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
         builder.AddLocationRequest(mLocationRequest);
         LocationSettingsRequest locationSettingsRequest = builder.Build();
         // Before requesting location update, invoke checkLocationSettings to check device settings.
         Task locationSettingsResponseTask = mSettingsClient.CheckLocationSettings(locationSettingsRequest);
         locationSettingsResponseTask
         .AddOnSuccessListener(new LocCallSettOnSuccessListenerImpl(mFusedLocationProviderClient, mLocationRequest, mLocationCallback))
         .AddOnFailureListener(new LocCallSettOnFailureListenerImpl(this));
     }
     catch (Exception e)
     {
         LocationLog.Error(TAG, "requestLocationUpdatesWithCallback exception:" + e.Message);
     }
 }
Ejemplo n.º 26
0
        public void Try_RegisterLocationLog()
        {
            try
            {
                LocationLog log = new LocationLog() {PoIId = "My bedroom", Accuracy = (float)0.0, Bearing = (float)123.01532, Latitude = 56.25153, Longitude = 6.235, Altitude = 51.212, Speed = (float)2.3};
                //log = LatiProvider
                //    .Latis
                //    .RegisterLocation(log);
                log = LatiPortal
                    .Latis
                    .RegisterLocation(log);
                Console.WriteLine("Log: {0} - Lon:{1}", log.PoIId, log.Longitude);

            }
            catch (Exception exception)
            {
                Assert.Fail(exception.Message);               
            }
        }
        public async Task <LocationLog> Get(long Id)
        {
            LocationLog LocationLog = await DataContext.LocationLog.AsNoTracking()
                                      .Where(x => x.Id == Id)
                                      .Where(x => x.DeletedAt == null)
                                      .Select(x => new LocationLog()
            {
                CreatedAt      = x.CreatedAt,
                UpdatedAt      = x.UpdatedAt,
                Id             = x.Id,
                PreviousId     = x.PreviousId,
                AppUserId      = x.AppUserId,
                Latitude       = x.Latitude,
                Longtitude     = x.Longtitude,
                UpdateInterval = x.UpdateInterval,
                AppUser        = x.AppUser == null ? null : new AppUser
                {
                    Id          = x.AppUser.Id,
                    Username    = x.AppUser.Username,
                    Password    = x.AppUser.Password,
                    DisplayName = x.AppUser.DisplayName,
                    Email       = x.AppUser.Email,
                    Phone       = x.AppUser.Phone,
                },
                Previous = x.Previous == null ? null : new LocationLog
                {
                    Id             = x.Previous.Id,
                    PreviousId     = x.Previous.PreviousId,
                    AppUserId      = x.Previous.AppUserId,
                    Latitude       = x.Previous.Latitude,
                    Longtitude     = x.Previous.Longtitude,
                    UpdateInterval = x.Previous.UpdateInterval,
                },
            }).FirstOrDefaultAsync();

            if (LocationLog == null)
            {
                return(null);
            }

            return(LocationLog);
        }
Ejemplo n.º 28
0
        public async Task <bool> ValidateId(LocationLog LocationLog)
        {
            LocationLogFilter LocationLogFilter = new LocationLogFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = LocationLog.Id
                },
                Selects = LocationLogSelect.Id
            };

            int count = await UOW.LocationLogRepository.Count(LocationLogFilter);

            if (count == 0)
            {
                LocationLog.AddError(nameof(LocationLogValidator), nameof(LocationLog.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
        public async Task <bool> Update(LocationLog LocationLog)
        {
            LocationLogDAO LocationLogDAO = DataContext.LocationLog.Where(x => x.Id == LocationLog.Id).FirstOrDefault();

            if (LocationLogDAO == null)
            {
                return(false);
            }
            LocationLogDAO.Id             = LocationLog.Id;
            LocationLogDAO.PreviousId     = LocationLog.PreviousId;
            LocationLogDAO.AppUserId      = LocationLog.AppUserId;
            LocationLogDAO.Latitude       = LocationLog.Latitude;
            LocationLogDAO.Longtitude     = LocationLog.Longtitude;
            LocationLogDAO.UpdateInterval = LocationLog.UpdateInterval;
            LocationLogDAO.UpdatedAt      = StaticParams.DateTimeNow;
            await DataContext.SaveChangesAsync();

            await SaveReference(LocationLog);

            return(true);
        }
Ejemplo n.º 30
0
 public static void RequestActivityPermission(Context context)
 {
     if (Build.VERSION.SdkInt <= BuildVersionCodes.P)
     {
         if (ActivityCompat.CheckSelfPermission(context, "com.huawei.hms.permission.ACTIVITY_RECOGNITION") == Permission.Denied)
         {
             string[] permissions = { "com.huawei.hms.permission.ACTIVITY_RECOGNITION" };
             ActivityCompat.RequestPermissions((Activity)context, permissions, 1);
             LocationLog.Info(TAG, "requestActivityTransitionButtonHandler: apply permission");
         }
     }
     else
     {
         if (ActivityCompat.CheckSelfPermission(context, "android.permission.ACTIVITY_RECOGNITION") == Permission.Denied)
         {
             string[] permissions = { "android.permission.ACTIVITY_RECOGNITION" };
             ActivityCompat.RequestPermissions((Activity)context, permissions, 2);
             LocationLog.Info(TAG, "requestActivityTransitionButtonHandler: apply permission");
         }
     }
 }
Ejemplo n.º 31
0
        public void OnFailure(Java.Lang.Exception e)
        {
            LocationLog.Error(TAG, "checkLocationSetting onFailure:" + e.Message);
            int statusCode = ((ApiException)e).StatusCode;

            switch (statusCode)
            {
            case LocationSettingsStatusCodes.ResolutionRequired:
                try
                {
                    //When the startResolutionForResult is invoked, a dialog box is displayed, asking you to open the corresponding permission.
                    ResolvableApiException rae = (ResolvableApiException)e;
                    rae.StartResolutionForResult(callbackActivity, 0);
                }
                catch (IntentSender.SendIntentException sie)
                {
                    LocationLog.Error(TAG, "PendingIntent unable to execute request.");
                }
                break;
            }
        }