public void Post(string title, string summary, IEnumerable <NamedAction> tasks) { var post = new EventPost(title, summary, tasks); Items.Add(post); OnPost.InvokeIfExists(post); }
/* ---------FETCH EVENTS,DOCUMENTS,LOCATION,FEEDS,POST--------------*/ public void createEvent(EventPost events) { try { if (events.event_document_id != null) { if (events.list_document_id.Count() > 1) { events.event_document_id = string.Join(",", events.list_document_id); } } else if (events.event_gpslocation_id != null) { if (events.list_gpslocation_id.Count() > 1) { events.event_gpslocation_id = string.Join(",", events.list_gpslocation_id); } } objUserInfoDAL.createEvent(events); } catch (Exception ex) { CubitExceptionUtility.CubitExceptionLog(ex.Message + "BAL: Error while creating a event" + ex.StackTrace + " " + ex.InnerException, this.GetType().BaseType.Name.ToString(), DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString()); } }
private List <PersistentEvent> ParseEventPost(EventPost ep) { byte[] data = ep.Data; if (!String.IsNullOrEmpty(ep.ContentEncoding)) { data = data.Decompress(ep.ContentEncoding); } var encoding = Encoding.UTF8; if (!String.IsNullOrEmpty(ep.CharSet)) { encoding = Encoding.GetEncoding(ep.CharSet); } string input = encoding.GetString(data); List <PersistentEvent> events = _eventParserPluginManager.ParseEvents(input, ep.ApiVersion, ep.UserAgent); events.ForEach(e => { // set the project id on all events e.ProjectId = ep.ProjectId; }); return(events); }
public EventsBarViewModel(EventPost post) { Post = post; CreateTasks(post); StartTimer(); }
public async Task <IActionResult> Create(EventPost eventPost) //Here is where I realized I messed up naming this event *Fixed { if (ModelState.IsValid) { eventPost.Slug = eventPost.Name.ToLower().Replace(" ", "-"); var slug = await context.EventPosts.FirstOrDefaultAsync(x => x.Slug == eventPost.Slug); if (slug != null) { ModelState.AddModelError("", "This event alreay exists"); return(View(eventPost)); } context.Add(eventPost); await context.SaveChangesAsync(); TempData["Success"] = "The event has been added!"; return(RedirectToAction("Index")); } return(View(eventPost)); }
public async Task <string> EnqueueAsync(EventPost data, Stream stream, CancellationToken cancellationToken = default) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } data.FilePath = data.ShouldArchive ? GetArchivePath(SystemClock.UtcNow, data.ProjectId, $"{Guid.NewGuid():N}.json") : Path.Combine("q", $"{Guid.NewGuid():N}.json"); var saveTask = data.ShouldArchive ? _storage.SaveObjectAsync(data.FilePath, (EventPostInfo)data, cancellationToken) : Task.FromResult(true); var savePayloadTask = _storage.SaveFileAsync(Path.ChangeExtension(data.FilePath, ".payload"), stream, cancellationToken); if (!await saveTask.AnyContext()) { using (_logger.BeginScope(new ExceptionlessState().Organization(data.OrganizationId).Property(nameof(EventPostInfo), data))) _logger.LogError("Unable to save event post info"); await savePayloadTask.AnyContext(); return(null); } if (!await savePayloadTask.AnyContext()) { using (_logger.BeginScope(new ExceptionlessState().Organization(data.OrganizationId).Property(nameof(EventPostInfo), data))) _logger.LogError("Unable to save event post payload"); return(null); } return(await _queue.EnqueueAsync(data).AnyContext()); }
public async Task <IActionResult> Edit(int Id, EventPost eventPost) //Here is where I realized I messed up naming this event *Fixed { ViewBag.CategoryId = new SelectList(context.Categories.OrderBy(x => x.Sorting), "Id", "Name", eventPost.CategoryId); if (ModelState.IsValid) { eventPost.Slug = eventPost.Name.ToLower().Replace(" ", "-"); var slug = await context.EventPosts.Where(x => x.Id != Id).FirstOrDefaultAsync(x => x.Slug == eventPost.Slug); if (slug != null) { ModelState.AddModelError("", "This event alreay exists"); return(View(eventPost)); } context.Update(eventPost); await context.SaveChangesAsync(); TempData["Success"] = "The event has been updated!"; return(RedirectToAction("Index")); } return(View(eventPost)); }
public ActionResult <IEnumerable <string> > PostEvent(EventPost eventPost, string calendar) { var calendarId = new KalenderModel().GetCalendarId(calendar); if (calendarId == -1) { return(NotFound()); } if (!auth.CheckIfCalendarPermissions(eventPost, calendarId)) { return(Unauthorized()); } var result = model.PostEvent(calendarId, eventPost); if (result != null) { var path = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/veranstaltungen/{calendar}/{result}"; return(Created(path, null)); } else { return(BadRequest()); } }
public ActionResult <IEnumerable <string> > PutEvent(EventPost eventPost, string calendar, string uid) { var calendarId = new KalenderModel().GetCalendarId(calendar); if (calendarId == -1) { return(NotFound()); } if (!auth.CheckIfCalendarPermissions(eventPost, calendarId)) { return(Unauthorized()); } var result = model.PutEvent(calendarId, uid, eventPost); if (result) { return(NoContent()); } else { return(NotFound()); } }
private void button2_Click(object sender, EventArgs e) { //Create eventDTO EventPost eventDTO = new EventPost(); eventDTO.deviceEventID = 12314; eventDTO.eventCategoryID = 2; eventDTO.eventSeverityID = 5; eventDTO.type = "UNAUTHORIZED_OPENING"; eventDTO.parameters.Add(1414); eventDTO.parameters.Add(12); eventDTO.parameters.Add(13); eventDTO.username = "******"; eventDTO.dateUTC = 153464256; eventDTO.dateUTCStoredInGateway = 12489210347; eventDTO.smartBoxSN = "Sfw9498"; eventDTO.meterSN = "A49238"; eventDTO.isSynchronized = 2; eventDTO.priority = 5; eventDTO.isExecuted = 1; eventDTO.periodicalTaskID = 9999; //Try to POST readings to server try { var response = client.Post <EventPostResponse>("/event", eventDTO); label1.Text = response.responsesMsg; } catch (WebServiceException webEx) { //Get error Message label1.Text = webEx.GetStatus().ToString() + ": " + webEx.StatusDescription; } }
public void ReturnTrueWhenOnlyStartDateIsSpecified() { EventPost ev = new EventPost { StartTimeUtc = new DateTime(2018, 4, 30, 10, 10, 0) }; Assert.True(ev.IsSingleDayEvent); }
//GET /admin/events/details/id public async Task <IActionResult> Details(int id) { EventPost eventPost = await context.EventPosts.Include(x => x.Category).FirstOrDefaultAsync(x => x.Id == id); if (eventPost == null) { return(NotFound()); } return(View(eventPost)); }
public void ReturnFalseWhenStartAndEndDatesAreDifferent() { EventPost ev = new EventPost { StartTimeUtc = new DateTime(2018, 4, 30, 10, 10, 0), EndTimeUtc = new DateTime(2018, 5, 1) }; Assert.False(ev.IsSingleDayEvent); }
public void ReturnTrueWhenStartAndEndDatesAreEqual() { EventPost ev = new EventPost { StartTimeUtc = new DateTime(2018, 4, 30, 10, 10, 0), EndTimeUtc = new DateTime(2018, 4, 30) }; Assert.True(ev.IsSingleDayEvent); }
public JsonResult AddPost(EventPost Post) { db.Configuration.ProxyCreationEnabled = false; var post = Post; post.DatePosted = DateTime.Now; db.Posts.Add(post); db.SaveChanges(); post.Person = db.People.FirstOrDefault(m => m.Id == Post.PersonId); return(Json(post, JsonRequestBehavior.AllowGet)); }
private void Events_OnToast(EventPost post) { EventsControl = new EventsBarViewModel(post); EventsControl.RequestClose += () => { EventsControl = null; NotifyOfPropertyChange(() => EventsControl); }; NotifyOfPropertyChange(() => EventsControl); }
//GET /admin/events/edit/id public async Task <IActionResult> Edit(int id) { EventPost eventPost = await context.EventPosts.FindAsync(id); if (eventPost == null) { return(NotFound()); } ViewBag.CategoryId = new SelectList(context.Categories.OrderBy(x => x.Sorting), "Id", "Name", eventPost.CategoryId); return(View(eventPost)); }
/// <summary> /// Permet de mettre à jour un évenement /// </summary> /// <param name="eventPost"></param> /// <param name="eventId"></param> /// <returns>Evenement mis a jour</returns> public async Task <EventGet> UpdateEventAsync(EventPost eventPost, int eventId) { EventGet result = null; result = await this.SafeRequest(async() => { string response = await this._cob.UpdateEventAsync(eventPost, eventId); result = JsonConvert.DeserializeObject <EventGet>(response); return(result); }); return(result); }
public static List <Post> gitPosts(String githubUsername) { // define the post relationship between event types and their generators eventPostFactories["PushEvent"] = new ActionEventPost("pushed to"); eventPostFactories["CreateEvent"] = new ActionEventPost("created a new repository,"); // do a call to github events and hope, hope HOPE var client = new RestClient(); // var?!? client.BaseUrl = new Uri("https://api.github.com"); var request = new RestRequest(); request.Resource = "users/" + githubUsername + "/events"; // what could possibly go wrong???? var authenticator = new HttpBasicAuthenticator("o0v0o", "hellogithub1"); authenticator.Authenticate(client, request); var response = client.Execute <List <Event> >(request); if (response.ErrorException != null) { Post error = new Post(errorPost(response.ErrorException.Message), DateTime.UtcNow); // we couldn't get git info... soooooo return(new List <Post>(new Post[] { error })); } else { List <Post> posts = new List <Post>(); List <Event> events = response.Data; if (events.Count > 0) { foreach (Event evnt in events) { // bug(evnt.type); if (evnt.type != null && eventPostFactories.ContainsKey(evnt.type)) { EventPost postType = eventPostFactories[evnt.type]; if (postType != null) { posts.Add(new Post(postType.generate(evnt), evnt.getTimestamp())); } } } } return(posts); } }
[ResponseHeaderAddition] //Response header addition profile public object Post(EventPost receivedEvent) { EventPostResponse res = new EventPostResponse { responsesMsg = "a" }; //Check if the response status code is correct to store info in DB and send back response if (Response.StatusCode == 200) { Info.hmac = receivedEvent.type; res.responsesMsg = receivedEvent.parameters[0].ToString(); } return(res); }
public void CanConcurrentlyManageFiles() { Reset(); IFileStorage storage = GetStorage(); if (storage == null) { return; } const string queueFolder = "q"; const string archiveFolder = "archive"; var queueItems = new BlockingCollection <int>(); Parallel.For(0, 25, i => { var ev = new EventPost { ApiVersion = 2, CharSet = "utf8", ContentEncoding = "application/json", Data = Encoding.UTF8.GetBytes("{}"), IpAddress = "127.0.0.1", MediaType = "gzip", ProjectId = i.ToString(), UserAgent = "test" }; storage.SaveObject(Path.Combine(queueFolder, i + ".json"), ev); queueItems.Add(i); }); Assert.Equal(25, storage.GetFileList().Count()); Parallel.For(0, 50, i => { string path = Path.Combine(queueFolder, queueItems.Random() + ".json"); var eventPost = storage.GetEventPostAndSetActive(Path.Combine(queueFolder, RandomHelper.GetRange(0, 25) + ".json")); if (eventPost == null) { return; } if (RandomHelper.GetBool()) { storage.CompleteEventPost(path, eventPost.ProjectId, DateTime.UtcNow, true); } else { storage.SetNotActive(path); } }); }
public async Task <IActionResult> OnPost() { logger.LogDebug("Creating post with: {@CreateVM}", VM); var post = new EventPost { Title = VM.Title ?? "Untitled", Slug = VM.Slug, Description = VM.Description, BodyMarkdown = VM.Markdown }; post.RenderMarkdown(); await eventPosts.AddAsync(post); return(RedirectToPage("/Index", new { area = "Evlog" })); }
public async Task <string> PostEventAsync(EventPost eventPost) { string newUrl = string.Concat(BaseUrl, "events"); string body = JsonConvert.SerializeObject(eventPost); HttpResponseMessage responseMessage = await this._httpProvider.PostAsync(newUrl, this._authHeaders, body); if (!responseMessage.IsSuccessStatusCode) { throw new Exception("Un problème est survenu lors de l'envoie de la requête PostEventAsync."); } string response = await responseMessage.Content.ReadAsStringAsync(); return(response); }
private async Task <string> EnqueueEventPostAsync(PersistentEvent ev) { var eventPostInfo = new EventPost { OrganizationId = ev.OrganizationId, ProjectId = ev.ProjectId, ApiVersion = 2, CharSet = "utf-8", ContentEncoding = "gzip", MediaType = "application/json", UserAgent = "exceptionless-test", }; var stream = new MemoryStream(ev.GetBytes(_jsonSerializerSettings).Compress()); return(await _eventPostService.EnqueueAsync(eventPostInfo, stream).AnyContext()); }
//GET /admin/Events/delete/id public async Task <IActionResult> Delete(int id) { EventPost eventPost = await context.EventPosts.FindAsync(id); if (eventPost == null) { TempData["Error"] = "This event does not exist!"; } else { context.EventPosts.Remove(eventPost); await context.SaveChangesAsync(); TempData["Success"] = "The event has been deleted!"; } return(RedirectToAction("Index")); }
public static string Enqueue(this IQueue <EventPostFileInfo> queue, EventPost data, IFileStorage storage, bool shouldArchive = true) { string path = String.Format("q\\{0}.json", Guid.NewGuid().ToString("N")); try { if (!storage.SaveObject(path, data)) { return(null); } } catch (Exception ex) { Log.Error().Exception(ex).Message("Error saving event post data to storage.").Write(); } return(queue.Enqueue(new EventPostFileInfo { FilePath = path, ShouldArchive = shouldArchive })); }
private Task <string> EnqueueEventPostAsync(List <PersistentEvent> ev) { var first = ev.First(); var eventPostInfo = new EventPost(_options.EnableArchive) { OrganizationId = first.OrganizationId, ProjectId = first.ProjectId, ApiVersion = 2, CharSet = "utf-8", ContentEncoding = "gzip", MediaType = "application/json", UserAgent = "exceptionless-test", }; var stream = new MemoryStream(_serializer.SerializeToBytes(ev).Compress()); return(_eventPostService.EnqueueAsync(eventPostInfo, stream)); }
public static EventPost GetEventPostAndSetActive(this IFileStorage storage, string path) { EventPost eventPost = null; try { eventPost = storage.GetObject <EventPost>(path); if (eventPost == null) { return(null); } if (!storage.Exists(path + ".x") && !storage.SaveFile(path + ".x", String.Empty)) { return(null); } } catch (Exception ex) { Log.Error().Exception(ex).Message("Error retrieving event post data \"{0}\".", path).Write(); return(null); } return(eventPost); }
public JsonResult PostEventAttendSubmit(int pid, int eid, int eattId) { string message = string.Empty; string _loginUser = User.Identity.Name.ToString(); int _postId = pid; int _eventId = eid; int _eventAttendId = eattId; Post _post = db.Posts.Where(x => x.PostId == _postId && x.EventPostId == _eventId).FirstOrDefault(); EventPost _eventPost = _post.EventPost; EventAttendPerson _oldEventAttendPerson = _eventPost.EventAttendPersons.Where(x => x.EventPostId == _eventId && x.UserId == _loginUser).FirstOrDefault(); User _CurrUser = db.Users.Where(x => x.UserName == _loginUser).FirstOrDefault(); if (_eventPost != null) { bool isEvtAttend = false; if (_eventPost.EventAttendPersons.Count() > 0) { //User vUsr = _oldEventAttendPerson.User; if (_oldEventAttendPerson != null) { isEvtAttend = true; //for remove like _eventPost.EventAttendPersons.Remove(_oldEventAttendPerson); db.SaveChanges(); EventAttendPerson _newUpdAttendPerson = new EventAttendPerson(); _newUpdAttendPerson.EventPostId = _eventPost.Id; _newUpdAttendPerson.EventAttendTypeId = _eventAttendId; _newUpdAttendPerson.UserId = _CurrUser.UserName; _eventPost.EventAttendPersons.Add(_newUpdAttendPerson); db.EventPosts.Attach(_eventPost); db.Entry(_eventPost).State = EntityState.Modified; db.SaveChanges(); } } if (isEvtAttend == false) { EventAttendPerson _newCrtAttendPerson = new EventAttendPerson(); _newCrtAttendPerson.EventPostId = _eventPost.Id; _newCrtAttendPerson.EventAttendTypeId = _eventAttendId; _newCrtAttendPerson.UserId = _CurrUser.UserName; _eventPost.EventAttendPersons.Add(_newCrtAttendPerson); db.EventPosts.Attach(_eventPost); db.Entry(_eventPost).State = EntityState.Modified; db.SaveChanges(); _oldEventAttendPerson = _newCrtAttendPerson; } } else { message = "Donot insert"; } return(Json(new { Html = this.RenderPartialView("_PostEventAttendPerson", _eventPost), Message = message }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Invoqué lorsque cette page est sur le point d'être affichée dans un frame. /// </summary> /// <param name="e">Données d’événement décrivant la manière dont l’utilisateur a accédé à cette page. /// Ce paramètre est généralement utilisé pour configurer la page.</param> protected override async void OnNavigatedTo(NavigationEventArgs e) { // TODO: préparer la page pour affichage ici. // TODO: si votre application comporte plusieurs pages, assurez-vous que vous // gérez le bouton Retour physique en vous inscrivant à l’événement // Windows.Phone.UI.Input.HardwareButtons.BackPressed. // Si vous utilisez le NavigationHelper fourni par certains modèles, // cet événement est géré automatiquement. this._mapService.StartFollowUser(Map); await this._mapService.CenterMapOnUserPositionAsync(Map); await this.DisplayEvents(); if (e.Parameter != null) { if (e.Parameter.GetType() == typeof(LoginModel)) { LoginModel loginModel = e.Parameter as LoginModel; if (loginModel.Type == TypeEnum.Login) { try { await this.Login(loginModel); // pas le bon bouton? CommandBar.SecondaryCommands.RemoveAt(0); this.AddDecoButton(); } catch (Exception ex) { this.GenerateMessageDialog("Erreur lors de la connexion, vérifiez vos identifiants de connexion."); } } else { try { User user = await this._apiService.RegisterAsync(loginModel.Login, loginModel.Pass, loginModel.Mail); await this.Login(loginModel); CommandBar.SecondaryCommands.RemoveAt(0); this.AddDecoButton(); } catch (Exception ex) { this.GenerateMessageDialog("Erreur lors de l'enregistrement."); } } } else if (e.Parameter.GetType() == typeof(EventModel)) { try { EventModel eventModel = e.Parameter as EventModel; // timestamp = dt(utc) - dt(1970) + dt - dt // timestamp = dt - dt(1970) + dt(utc) - dt et dt(utc) - dt = dtnow(utc) - dtnow int offset = (int)DateTime.UtcNow.Subtract(DateTime.Now).TotalSeconds; int timestamp = (int)eventModel.Date.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds + offset; string address = string.Format("{0} {1}", eventModel.Address, eventModel.City); GeolocByAddress geoloc = await this._apiService.GetGeolocAsync(address); EventPost eventPost = new EventPost() { Name = eventModel.Name, Date = timestamp, Latitude = geoloc.Latitude, Longitude = geoloc.Longitude, Address = eventModel.Address, City = eventModel.City }; EventGet eventGet = await this._apiService.PostEventAsync(eventPost); this.DisplayEvent(eventGet); this._eventList.Add(eventGet); } catch (Exception ex) { this.GenerateMessageDialog("Erreur lors de l'envoi de l'évènement."); } } } }