public void Ask(AskParameters parameters) { var now = SystemDateTime.Now; var areYouOk = new AreYouOkActivity(); areYouOk.Sender = Users[parameters.SenderId]; areYouOk.Target = Users[parameters.TargetId]; areYouOk.IAmOk = false; AreYouOkActivities.Put(areYouOk); CurrentUnitOfWork.Checkpoint(); var list = areYouOk.Target.Devices.Select(x => new BodySend() { Token = x.Token, Body = "¿estas bien?", Title = "Encuentrame", Data = new { Created = now, Id = areYouOk.Id, SenderUserId = areYouOk.Target.Id, AskDatetime = areYouOk.Created, Type = "Areyouok.Ask", } }).ToList(); ExpoPushHelper.SendPushNotification(list); }
public void AskFromEvent(Event eventt) { var now = SystemDateTime.Now; var activities = Activities.Where(x => x.Event == eventt); foreach (var activity in activities) { var areYouOk = new AreYouOkEvent(); areYouOk.Event = eventt; areYouOk.Target = activity.User; areYouOk.IAmOk = false; AreYouOkEvents.Put(areYouOk); } CurrentUnitOfWork.Checkpoint(); var listAsks = AreYouOkEvents.Where(x => x.Event == eventt); foreach (var areYouOkEvent in listAsks) { var list = areYouOkEvent.Target.Devices.Select(x => new BodySend() { Token = x.Token, Body = "¿estas bien?", Title = "Encuentrame", Data = new { Created = now, Id = areYouOkEvent.Id, SenderUserId = areYouOkEvent.Target.Id, AskDatetime = areYouOkEvent.Created, Type = "Areyouok.Ask", } }).ToList(); ExpoPushHelper.SendPushNotification(list); } }
// GET: Database public ActionResult CreateDataMock(string password) { if (password != "destruir") { AddModelError("Contraseña incorrecta"); return(View("Index")); } //Users var userAdmin = new User() { Username = "******", Password = "******", Firstname = "Admin", Lastname = "Admin", Email = "*****@*****.**", Role = RoleEnum.Administrator, }; Users.Put(userAdmin); var business1 = new Business() { Name = "Pepsi Music", Cuit = "20287495782", Created = SystemDateTime.Now, Address = new Address() { City = "CABA", FloorAndDepartament = "1 'C'", Number = "243", Province = "CABA", Street = "Aguirre", Zip = "1414", } }; Businesses.Put(business1); var user3 = new User() { Username = "******", Password = "******", Firstname = "juan", Lastname = "organizador", Email = "*****@*****.**", Role = RoleEnum.EventAdministrator, Business = business1, }; Users.Put(user3); var user4 = new User() { Username = "******", Password = "******", Firstname = "fernando", Lastname = "organizador", Email = "*****@*****.**", Role = RoleEnum.EventAdministrator, Business = business1, }; Users.Put(user4); var eventt1 = new Event() { Name = "Obelisco", BeginDateTime = SystemDateTime.Now.AddHours(-3), EndDateTime = SystemDateTime.Now.AddHours(3), Organizer = user3, Status = EventStatusEnum.InProgress, Address = new Address() { City = "CABA", FloorAndDepartament = "", Number = "0", Province = "CABA", Street = "Obelisco", Zip = "1414", }, Latitude = (decimal) - 34.60373, Longitude = (decimal) - 58.38157, }; Events.Put(eventt1); var eventt2 = new Event() { Name = "UTN", BeginDateTime = SystemDateTime.Now.AddHours(1), EndDateTime = SystemDateTime.Now.AddHours(3), Organizer = user4, Status = EventStatusEnum.Pending, Address = new Address() { City = "CABA", FloorAndDepartament = "", Number = "953", Province = "CABA", Street = "Medrano", Zip = "1414", }, Latitude = (decimal) - 34.59858, Longitude = (decimal) - 58.41989, }; Events.Put(eventt2); var dayRandom = new Random(SystemDateTime.Now.Millisecond); for (int ss = 0; ss < 50; ss++) { var bgdt = SystemDateTime.Now.AddDays(-1 * dayRandom.Next(0, 360)); var ev = new Event() { Name = $"Evento de prueba {ss}", BeginDateTime = bgdt, EndDateTime = bgdt.AddHours(3), Organizer = user4, Status = bgdt < SystemDateTime.Now ? EventStatusEnum.Completed : EventStatusEnum.InProgress, Address = new Address() { City = "CABA", FloorAndDepartament = "", Number = "953", Province = "CABA", Street = "Medrano", Zip = "1414", }, Latitude = (decimal) - 34.59858, Longitude = (decimal) - 58.41989, }; if (dayRandom.Next(0, 360) < 36) { ev.EmergencyDateTime = bgdt.AddHours(1); if (ev.Status == EventStatusEnum.InProgress) { ev.Status = EventStatusEnum.InEmergency; } } Events.Put(ev); } CreateUsers(); CurrentUnitOfWork.Checkpoint(); var listOfUsers = Users.Where(x => x.Role == RoleEnum.User).ToList(); foreach (var user in listOfUsers) { var activityIn = new Activity() { BeginDateTime = SystemDateTime.Now.AddDays(-1), EndDateTime = SystemDateTime.Now, Event = eventt1, Latitude = eventt1.Latitude, Longitude = eventt1.Longitude, Name = "actividad 1", User = user }; Activities.Put(activityIn); } foreach (var user in listOfUsers) { var activityIn = new Activity() { BeginDateTime = SystemDateTime.Now.AddDays(3), EndDateTime = SystemDateTime.Now.AddDays(4), Event = eventt2, Latitude = eventt2.Latitude, Longitude = eventt2.Longitude, Name = "actividad 2", User = user }; Activities.Put(activityIn); } var dictionary = new Dictionary <int, dynamic>(); foreach (var user in listOfUsers) { var position = new Position() { Latitude = eventt1.Latitude, Longitude = eventt1.Longitude, Creation = eventt1.BeginDateTime, UserId = user.Id, }; Positions.Put(position); dictionary[user.Id] = new { Latitude = eventt1.Latitude, Longitude = eventt1.Longitude }; } var rnd = new Random(DateTime.Now.Millisecond); for (int ii = 0; ii < 180; ii = ii + 3) { foreach (var user in listOfUsers) { var position = new Position() { Latitude = dictionary[user.Id].Latitude + (decimal)rnd.Next(-3, 3) / 10000, Longitude = dictionary[user.Id].Longitude + (decimal)rnd.Next(-3, 3) / 10000, Creation = eventt1.BeginDateTime.AddMinutes(ii), UserId = user.Id, }; Positions.Put(position); dictionary[user.Id] = new { Latitude = position.Latitude, Longitude = position.Longitude }; } } CurrentUnitOfWork.Checkpoint(); EventCommand.DeclareEmergency(eventt1.Id); CurrentUnitOfWork.Checkpoint(); EventCommand.StartCollaborativeSearch(eventt1.Id); CurrentUnitOfWork.Checkpoint(); foreach (var user in listOfUsers) { var nmb = rnd.Next(0, 10); if (nmb.NotIn(new[] { 0, 5, 8 })) { if (nmb % 2 == 0) { AreYouOkCommand.Reply(new AreYouOkCommand.ReplyParameters() { UserId = user.Id, IAmOk = true, }); } else if (nmb % 2 != 0) { AreYouOkCommand.Reply(new AreYouOkCommand.ReplyParameters() { UserId = user.Id, IAmOk = false, }); } } } CurrentUnitOfWork.Checkpoint(); var soughtPeople = AreYouOkEvents.Where(x => x.Event == eventt1 && x.ReplyDatetime == null).ToList(); var index = soughtPeople.Count; foreach (var areYouOkEvent in AreYouOkEvents.Where(x => x.Event == eventt1 && x.IAmOk && x.ReplyDatetime != null)) { var nmb = rnd.Next(0, 10); if (nmb.NotIn(new[] { 0, 5, 8 })) { if (nmb % 2 == 0) { var soughtPersonAswer = new SoughtPersonAnswer() { When = SystemDateTime.Now, Seen = true, IsOk = nmb.NotIn(new[] { 2 }), SourceUser = areYouOkEvent.Target, TargetUser = soughtPeople[rnd.Next(1, index) - 1].Target, }; SoughtPersonAnswers.Put(soughtPersonAswer); } else if (nmb % 2 != 0) { var soughtPersonAswer = new SoughtPersonAnswer() { When = SystemDateTime.Now, Seen = false, SourceUser = areYouOkEvent.Target, TargetUser = soughtPeople[rnd.Next(1, index) - 1].Target, }; SoughtPersonAnswers.Put(soughtPersonAswer); } } } return(View("IndexMessage", null, "Los datos de prueba se creo con exito")); }