private static OtlpTrace.Span.Types.Event ToOtlpEvent(ActivityEvent activityEvent) { var otlpEvent = new OtlpTrace.Span.Types.Event { Name = activityEvent.Name, TimeUnixNano = (ulong)activityEvent.Timestamp.ToUnixTimeNanoseconds(), }; foreach (var attribute in from tag in activityEvent.Tags let attribute = ToOtlpAttributes(tag) where attribute != null && attribute.Any() select attribute) { otlpEvent.Attributes.AddRange(attribute); } return(otlpEvent); }
// Wrap event invocations inside a protected virtual method // to allow derived classes to override the event invocation behavior private static void OnRaiseActivityEvent(IActivitySender sender, ActivityEventArgs args) { //// Make a temporary copy of the event to avoid possibility of //// a race condition if the last subscriber unsubscribes //// immediately after the null check and before the event is raised. //EventHandler<ActivityEventArgs> handler = RaiseActivityEvent; //// Event will be null if there are no subscribers //if (handler != null) //{ // //// Format the string to send inside the CustomEventArgs parameter // //e.Message += $" at {DateTime.Now}"; // // Use the () operator to raise the event. // handler(sender, e); //} ActivityEvent?.Invoke(sender, args); }
public async Task <IActionResult> Create(int cityId, [Bind("Id,ActivityName,Description,ActivityWebsite,ApplicationUserId,CityId")] ActivityEvent activityEvent) { var user = await GetCurrentUserAsync(); activityEvent.CityId = cityId; activityEvent.ApplicationUserId = user.Id; if (ModelState.IsValid) { _context.Add(activityEvent); await _context.SaveChangesAsync(); return(RedirectToAction("Details", "Cities", new { id = cityId })); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", activityEvent.ApplicationUserId == user.Id); ViewData["CityId"] = new SelectList(_context.City, "Id", "CityName", activityEvent.CityId); return(View(activityEvent)); }
public static JaegerLog ToJaegerLog(this ActivityEvent timedEvent) { var jaegerTags = new EventTagsEnumerationState { Tags = PooledList <JaegerTag> .Create(), }; timedEvent.EnumerateTags(ref jaegerTags); if (!jaegerTags.HasEvent) { // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk_exporters/jaeger.md#events PooledList <JaegerTag> .Add(ref jaegerTags.Tags, new JaegerTag("event", JaegerTagType.STRING, vStr : timedEvent.Name)); } // TODO: Use the same function as JaegerConversionExtensions or check that the perf here is acceptable. return(new JaegerLog(timedEvent.Timestamp.ToEpochMicroseconds(), jaegerTags.Tags)); }
public IActionResult GenerateActivity(ActivityEvent newEvent) { if (ModelState.IsValid) { Join newJoin = new Join(); newEvent.UserID = (int)HttpContext.Session.GetInt32("UserId"); context.ActivityList.Add(newEvent); context.SaveChanges(); newJoin.ActivityEventId = newEvent.ActivityEventId; newJoin.UserId = newEvent.UserID; context.Joiners.Add(newJoin); context.SaveChanges(); return(Redirect($"{newEvent.ActivityEventId}")); } else { return(View("Create")); } }
// Protected methods protected virtual async Task ProcessBatch(List <BatchItem <TKey, TDbEntity> > batch, CancellationToken cancellationToken) { using var activity = FusionTrace.StartActivity(ProcessBatchOperationName); if (activity != null) { var tags = new ActivityTagsCollection { { "batchSize", batch.Count } }; var activityEvent = new ActivityEvent(ProcessBatchOperationName, tags: tags); activity.AddEvent(activityEvent); } var dbContext = CreateDbContext(); await using var _ = dbContext.ConfigureAwait(false); var keys = new HashSet <TKey>(); foreach (var item in batch) { if (!item.TryCancel(cancellationToken)) { keys.Add(item.Input); } } var pEntity = Expression.Parameter(typeof(TDbEntity), "e"); var eKey = KeyExtractorExpressionBuilder(pEntity); var eBody = Expression.Call(Expression.Constant(keys), ContainsMethod, eKey); var eLambda = (Expression <Func <TDbEntity, bool> >)Expression.Lambda(eBody, pEntity); var query = QueryTransformer(dbContext.Set <TDbEntity>().Where(eLambda)); var entities = await query .ToDictionaryAsync(KeyExtractor, cancellationToken) .ConfigureAwait(false); PostProcessor(entities); foreach (var item in batch) { entities.TryGetValue(item.Input, out var entity); item.SetResult(Result.Value(entity) !, cancellationToken); } }
protected virtual Activity?StartActivity(ICommand command, CommandContext context) { if (!ShouldTrace(command, context)) { return(null); } var operationName = command.GetType().GetOperationName("Run"); var activity = CommanderTrace.StartActivity(operationName); if (activity != null) { var tags = new ActivityTagsCollection { { "command", command.ToString() } }; var activityEvent = new ActivityEvent(operationName, tags: tags); activity.AddEvent(activityEvent); } return(activity); }
/// <summary> /// Converts the supplied IOsbideEvent into a zipped, binary format /// </summary> /// <param name="evt"></param> /// <returns></returns> public static byte[] ToZippedBinary(ActivityEvent evt) { var memStream = new MemoryStream(); var zipStream = new MemoryStream(); var serializer = new BinaryFormatter(); serializer.Serialize(memStream, evt); //go back to position zero so that the zip file can read the memory stream memStream.Position = 0; //zip up to save space using (var zip = new ZipFile()) { zip.AddEntry(evt.EventName, memStream); zip.Save(zipStream); zipStream.Position = 0; } return(zipStream.ToArray()); }
public void SeparatesStreamsForDevelopers() { var event1 = new ActivityEvent { TriggeredAt = _someDateTime }; var event2 = new ActivityEvent { TriggeredAt = _someDateTime + WindowSpan }; var event3 = new ActivityEvent { TriggeredAt = _someDateTime + WindowSpan + WindowSpan }; WhenStreamIsProcessed(_someDeveloper, event1, event2); var otherDeveloper = TestFactory.SomeDeveloper(); WhenStreamIsProcessed(otherDeveloper, event1, event2, event3); AssertActivityStream(_someDeveloper, _someDateTime.Date, Activity.Away, Activity.Away); AssertActivityStream(otherDeveloper, _someDateTime.Date, Activity.Away, Activity.Away, Activity.Away); }
private void FireMouseActivity(object sender, MouseEventArgs e) { var now = _dateUtils.Now; if (HasOpenPeriod() && IsInactive(now)) { _currentEvent.TerminatedAt = _lastActivity; EndPeriod(); } if (_focusHelper.IsCurrentApplicationActive()) { if (!HasOpenPeriod()) { _currentEvent = Create <ActivityEvent>(); _currentEvent.TriggeredBy = EventTrigger.Click; } _lastActivity = now; } }
public static JaegerLog ToJaegerLog(this ActivityEvent timedEvent) { var tags = new PooledListState <JaegerTag> { Created = true, List = PooledList <JaegerTag> .Create(), }; DictionaryEnumerator <string, object, PooledListState <JaegerTag> > .AllocationFreeForEach( timedEvent.Attributes, ref tags, ProcessTagRef); // Matches what OpenTracing and OpenTelemetry defines as the event name. // https://github.com/opentracing/specification/blob/master/semantic_conventions.md#log-fields-table // https://github.com/open-telemetry/opentelemetry-specification/pull/397/files PooledList <JaegerTag> .Add(ref tags.List, new JaegerTag("message", JaegerTagType.STRING, vStr : timedEvent.Name)); // TODO: Use the same function as JaegerConversionExtensions or check that the perf here is acceptable. return(new JaegerLog(timedEvent.Timestamp.ToEpochMicroseconds(), tags.List)); }
public IActionResult viewActivityEvent(int activityId) { int?UserId = HttpContext.Session.GetInt32("UserId"); if (UserId != null) { User currentUser = _context.users.SingleOrDefault(u => u.id == UserId); ActivityEvent currentActivityEvent = _context.activities.SingleOrDefault(w => w.id == activityId); List <RSVP> rsvps = _context.rsvps.Where(r => r.activity.id == activityId).Include(r => r.user).ToList(); ViewBag.currentActivityEvent = currentActivityEvent; ViewBag.currentUser = currentUser; ViewBag.rsvps = rsvps; return(View("Activity")); } else { return(View("Index")); } }
public override void OnEnd(LogRecord data) { if (Activity.Current == null) { return; } var tags = new ActivityTagsCollection { { nameof(data.CategoryName), data.CategoryName }, { nameof(data.LogLevel), data.LogLevel }, { nameof(data.State), data.State.ToString() } }; var activityEvent = new ActivityEvent("log", data.Timestamp, tags); Activity.Current.AddEvent(activityEvent); if (data.Exception != null) { Activity.Current.RecordException(data.Exception); } }
public void InsertUpdateDelete() { FeedPostEvent log = new FeedPostEvent() { SenderId = 1, Comment = "This is a test FeedPostEvent.", CourseId = 3, SolutionName = "TestPost" }; using (SqlConnection conn = DBHelper.GetNewConnection()) { ////////////////////////////////////////////////// // necessary code to insert feed post into the DB // this comes from PostFeedItem in the OSBLE.Web // FeedController ////////////////////////////////////////////////// using (var cmd = log.GetInsertCommand()) { cmd.Connection = conn; conn.Open(); cmd.ExecuteScalar(); conn.Close(); } string feedPostText = "This is a test FeedPostEvent."; string findPost = "SELECT * " + "FROM FeedPostEvents " + "WHERE Comment = @Text"; var checkPost = conn.Query <FeedPostEvent>(findPost, new { Text = feedPostText }).FirstOrDefault(); int eventLogId = checkPost.EventLogId; // these two Items should be non-null Assert.AreEqual(feedPostText, checkPost.Comment); ////////////////////////////////////////////////// // necessary code to update feed post into the DB // this comes from EditFeedItem in the OSBLE.Web // FeedController ////////////////////////////////////////////////// string updatePostText = "This is a test update to a FeedPostEvent."; DBHelper.EditFeedPost(eventLogId, updatePostText, conn); string findUpdate = "SELECT * " + "FROM FeedPostEvents " + "WHERE Comment = @Text "; checkPost = conn.Query <FeedPostEvent>(findUpdate, new{ Text = updatePostText }).FirstOrDefault(); Assert.AreEqual(checkPost.Comment, updatePostText); ////////////////////////////////////////////////// // necessary code to delete feed post into the DB // this comes from DeleteFeedPost in the OSBLE.Web // FeedController ////////////////////////////////////////////////// // this is a soft delete, and marks the table entry as isdeleted // the sproc will not pull these from the DB, but leave them intact // for analytics purposes DBHelper.DeleteFeedPostEvent(checkPost.EventLogId, conn); string findDeletedItem = "SELECT * " + "FROM EventLogs " + "WHERE Id = @EventLogId " + "AND IsDeleted = 1 "; // assuming this item is pulled from the DB, then it is "Deleted" ActivityEvent checkEventLog = conn.Query <ActivityEvent>(findDeletedItem, checkPost).FirstOrDefault(); Assert.AreNotEqual(null, checkEventLog); } }
public ActivityQuery Type(ActivityEvent type) { return(AddParameter("activityTypeId[]", type)); }
public IActionResult rsvpActivityEventPage(int activityId) { int?UserId = HttpContext.Session.GetInt32("UserId"); if (UserId != null) { User currentUser = _context.users.SingleOrDefault(u => u.id == UserId); ActivityEvent currentActivityEvent = _context.activities.SingleOrDefault(w => w.id == activityId); List <RSVP> thisUsersEvents = _context.rsvps.Where(r => r.user.id == currentUser.id).Include(r => r.activity).ToList(); RSVP checkDuplicate = _context.rsvps.SingleOrDefault(r => r.user.id == currentUser.id && r.activity.id == currentActivityEvent.id); RSVP checkConflict = _context.rsvps.SingleOrDefault(r => r.user.id == currentUser.id && r.activity.date == currentActivityEvent.date && r.activity.id != currentActivityEvent.id); string checkConflict2 = null; int thiseventfulldurationmin = 0; if (currentActivityEvent.durationtime == "Minutes") { thiseventfulldurationmin = currentActivityEvent.duration; } else if (currentActivityEvent.durationtime == "Hours") { thiseventfulldurationmin = currentActivityEvent.duration * 60; } else { thiseventfulldurationmin = currentActivityEvent.duration * 1440; } foreach (var e in thisUsersEvents) { if (e.activity.durationtime == "Minutes") { int fulldurationminutes = e.activity.duration; DateTime starttime = e.activity.date; DateTime endtime = starttime.AddMinutes(fulldurationminutes); DateTime thisStarttime = currentActivityEvent.date; DateTime thisEndtime = thisStarttime.AddMinutes(thiseventfulldurationmin); if (currentActivityEvent.date >= starttime && currentActivityEvent.date <= endtime && currentActivityEvent.id != e.activity.id) { checkConflict2 = "YUP!"; } else if (e.activity.date >= thisStarttime && e.activity.date <= thisEndtime && currentActivityEvent.id != e.activity.id) { checkConflict2 = "YUP!"; } } else if (e.activity.durationtime == "Hours") { int fulldurationminutes = e.activity.duration * 60; DateTime starttime = e.activity.date; DateTime endtime = starttime.AddMinutes(fulldurationminutes); DateTime thisStarttime = currentActivityEvent.date; DateTime thisEndtime = thisStarttime.AddMinutes(thiseventfulldurationmin); if (currentActivityEvent.date >= starttime && currentActivityEvent.date <= endtime && currentActivityEvent.id != e.activity.id) { checkConflict2 = "YUP!"; } else if (e.activity.date >= thisStarttime && e.activity.date <= thisEndtime && currentActivityEvent.id != e.activity.id) { checkConflict2 = "YUP!"; } } else { int fulldurationminutes = e.activity.duration * 1440; DateTime starttime = e.activity.date; DateTime endtime = starttime.AddMinutes(fulldurationminutes); DateTime thisStarttime = currentActivityEvent.date; DateTime thisEndtime = thisStarttime.AddMinutes(thiseventfulldurationmin); if (currentActivityEvent.date >= starttime && currentActivityEvent.date <= endtime && currentActivityEvent.id != e.activity.id) { checkConflict2 = "YUP!"; } else if (e.activity.date >= thisStarttime && e.activity.date <= thisEndtime && currentActivityEvent.id != e.activity.id) { checkConflict2 = "YUP!"; } } } if (checkConflict != null || checkConflict2 != null) { TempData["message"] = "Schedule conflict! You are already attending an event at this time!"; return(RedirectToAction("activity", new { id = currentActivityEvent.id })); } else if (checkDuplicate != null) { _context.rsvps.Remove(checkDuplicate); _context.SaveChanges(); TempData["message"] = "You have left the event!"; return(RedirectToAction("activity", new { id = currentActivityEvent.id })); } else { RSVP newRSVP = new RSVP(); newRSVP.user = currentUser; newRSVP.activity = currentActivityEvent; _context.Add(newRSVP); _context.SaveChanges(); currentUser.rsvps.Add(newRSVP); currentActivityEvent.rsvps.Add(newRSVP); _context.SaveChanges(); TempData["message"] = "You have joined the event!"; return(RedirectToAction("activity", new { id = currentActivityEvent.id })); } } else { return(View("Index")); } }
public static IEnumerable <FeedItem> Get(DateTime dateReceivedMin, DateTime dateReceivedMax, int?minEventLogId, int?maxEventLogId, IEnumerable <int> logIds, IEnumerable <int> eventTypes, int?courseId, int?roleId, string commentFilter, IEnumerable <int> senderIds, int?topN) { using ( var connection = new SqlConnection(StringConstants.ConnectionString)) { var c = string.IsNullOrWhiteSpace(commentFilter) ? string.Empty : string.Format("%{0}%", commentFilter); var l = string.Join(",", logIds != null ? logIds.Where(i => i > 0).ToArray() : new int[0]); string t; // get possible posts with user names in them List <string> possibleNames = new List <string>(); List <int> possibleNameIds = new List <int>(); List <FeedItem> nameFilterFeedItems = new List <FeedItem>(); try { var etypes = eventTypes as int[] ?? eventTypes.ToArray(); t = etypes.Any() ? string.Format("{0}", string.Join(",", etypes)) : string.Empty; } catch (Exception ex) { t = ""; } // add all the possible names of users from the comment filter to a list of logIds if (!string.IsNullOrEmpty(commentFilter)) { possibleNames = commentFilter.Split(' ').ToList(); string nameSql = "SELECT u.ID " + "FROM UserProfiles u " + "WHERE u.FirstName LIKE @name OR u.LastName LIKE @name"; foreach (string name in possibleNames) { string partialName = "%" + name + "%"; int id = connection.Query <int>(nameSql, new { name = partialName }).Take(1).SingleOrDefault(); if (id > 0 && !possibleNameIds.Contains(id)) { possibleNameIds.Add(id); } } // Format names into a comma separated list int[] nameIds = possibleNameIds.ToArray(); string nID = nameIds.Any() ? string.Format("{0}", string.Join(",", nameIds)) : string.Empty; // sql query, -1 needs to be in the sender Ids list otherwise SQL will complain // This gets a list of all the event logs with either names of students/teachers, or by comment values string eventLogSql = string.Format(@"SELECT Id " + "FROM EventLogs " + "WHERE EventLogs.SenderId IN (-1{0}) OR EventLogs.Id IN ( " + "SELECT DISTINCT SourceEventLogId AS EventLogId " + "FROM LogCommentEvents " + "JOIN EventLogs e ON " + "e.Id = LogCommentEvents.EventLogId " + "WHERE Content LIKE @filter OR SenderId IN (-1{0}) " + "UNION " + "SELECT FeedPostEvents.EventLogId " + "FROM FeedPostEvents " + "WHERE FeedPostEvents.Comment LIKE @filter) ", string.IsNullOrEmpty(nID) ? nID : "," + nID); commentFilter = "%" + commentFilter + "%"; List <int> eventLogsForComments = connection.Query <int>(eventLogSql, new { filter = commentFilter }).ToList(); // recursive call to Get if (possibleNameIds.Count > 0 || eventLogsForComments.Count > 0) { nameFilterFeedItems.AddRange( Get( dateReceivedMin, dateReceivedMax, minEventLogId, maxEventLogId, eventLogsForComments, // send list of EventLogs to filter eventTypes, courseId, roleId, "", null, topN) ); } } var s = string.Join(",", senderIds != null ? senderIds.Where(i => i > 0).ToArray() : new int[0]); var multiResults = connection.QueryMultiple("dbo.GetActivityFeeds", new { DateReceivedMin = dateReceivedMin, DateReceivedMax = dateReceivedMax, MinEventLogId = minEventLogId ?? -1, MaxEventLogId = maxEventLogId ?? 2000000000, EventLogIds = l, EventTypes = t, CourseId = courseId ?? -1, RoleId = roleId ?? 99, CommentFilter = c, SenderIds = s, TopN = topN ?? 20 }, commandType: CommandType.StoredProcedure); // multiResults reads in order of the tables declared in dbo.GetActivityEvents // if you need to change these make sure that the table is read in the right order var eventLogs = multiResults.Read <ActivityEvent>().ToList(); //1 var users = multiResults.Read <UserProfile>().ToList(); //2 var askHelps = multiResults.Read <AskForHelpEvent>().ToList(); //3 var builds = multiResults.Read <BuildEvent>().ToList(); //4 var cutcopypastes = multiResults.Read <CutCopyPasteEvent>().ToList(); //5 var debugs = multiResults.Read <DebugEvent>().ToList(); //6 var editoractivites = multiResults.Read <EditorActivityEvent>().ToList(); //7 var exceptions = multiResults.Read <ExceptionEvent>().ToList(); //8 var feedPosts = multiResults.Read <FeedPostEvent>().ToList(); //9 var helpMark = multiResults.Read <HelpfulMarkGivenEvent>().ToList(); //10 var logComments = multiResults.Read <LogCommentEvent>().ToList(); //11 var saves = multiResults.Read <SaveEvent>().ToList(); //12 var submits = multiResults.Read <SubmitEvent>().ToList(); //13 // associate logComments with senderId List <LogCommentEvent> nonDeletedLogComments = new List <LogCommentEvent>(); //List<ActivityEvent> eventLogs = eventLogsTemp.Distinct(new ActivityEventEqualityComparer()).ToList(); foreach (LogCommentEvent log in logComments) { try { ActivityEvent e = eventLogs.SingleOrDefault(x => x.EventLogId == log.EventLogId); if (e == null) { continue; } log.SenderId = e.SenderId; if (!nonDeletedLogComments.Contains(log)) { nonDeletedLogComments.Add(log); } } catch (Exception ex) { // } } var itemsToAdd = NormalizeDataObjects( eventLogs, users, askHelps, builds, exceptions, feedPosts, nonDeletedLogComments, helpMark, submits, cutcopypastes, debugs, editoractivites, saves ); // remove duplicate items List <int> logIdsContained = nameFilterFeedItems.Select(x => x.Event.EventLogId).ToList(); foreach (var item in itemsToAdd) { if (!logIdsContained.Contains(item.Event.EventLogId)) { nameFilterFeedItems.Add(item); } } return(nameFilterFeedItems); } }
public IActionResult CreateActivity(ActivityEvent newactivity) { if (HttpContext.Session.GetInt32("UserId") == null) { return(RedirectToAction("Index")); } var j = newactivity.Time.Split(':').First(); var za = newactivity.Time.Split(':')[1]; var i = Int32.Parse(j); var m = Int32.Parse(za); var nh = DateTime.Now.Hour; var nm = DateTime.Now.Minute; if (newactivity.Date > DateTime.Today) { User user = _context.Users.Where(u => u.Id == (HttpContext.Session.GetInt32("UserId"))).FirstOrDefault(); if (ModelState.IsValid) { ActivityEvent creatingactivity = new ActivityEvent() { Creator = user, CreatorId = user.Id, Title = newactivity.Title, Time = newactivity.Time, Date = newactivity.Date, Duration = newactivity.Duration, Units = newactivity.Units, Description = newactivity.Description, }; _context.Activites.Add(creatingactivity); _context.SaveChanges(); return(RedirectToAction("Activity", new { actId = creatingactivity.ActivityId })); } else { return(View("AddActivity")); } } else if (newactivity.Date == DateTime.Today) { if (i > nh) { User user = _context.Users.Where(u => u.Id == (HttpContext.Session.GetInt32("UserId"))).FirstOrDefault(); if (ModelState.IsValid) { ActivityEvent creatingactivity = new ActivityEvent() { Creator = user, CreatorId = user.Id, Title = newactivity.Title, Time = newactivity.Time, Date = newactivity.Date, Duration = newactivity.Duration, Units = newactivity.Units, Description = newactivity.Description, }; _context.Activites.Add(creatingactivity); _context.SaveChanges(); return(RedirectToAction("Activity", new { actId = creatingactivity.ActivityId })); } else { return(View("AddActivity")); } } else if (i == nh) { if (m > nm) { User user = _context.Users.Where(u => u.Id == (HttpContext.Session.GetInt32("UserId"))).FirstOrDefault(); if (ModelState.IsValid) { ActivityEvent creatingactivity = new ActivityEvent() { Creator = user, CreatorId = user.Id, Title = newactivity.Title, Time = newactivity.Time, Date = newactivity.Date, Duration = newactivity.Duration, Units = newactivity.Units, Description = newactivity.Description, }; _context.Activites.Add(creatingactivity); _context.SaveChanges(); return(RedirectToAction("Activity", new { actId = creatingactivity.ActivityId })); } else { return(View("AddActivity")); } } else { TempData["Future"] = "Must enter a Time and Date in the future"; return(RedirectToAction("AddActivity")); } } else { TempData["Future"] = "Must enter a Time and Date in the future"; return(RedirectToAction("AddActivity")); } } else { TempData["Future"] = "Must enter a Time and Date in the future"; return(RedirectToAction("AddActivity")); } }
public IActionResult Join(int actId) { User user = _context.Users.Where(u => u.Id == (HttpContext.Session.GetInt32("UserId"))).FirstOrDefault(); ActivityEvent activity = _context.Activites.Where(w => w.ActivityId == actId).FirstOrDefault(); Guest existinglink = _context.Links.Where(u => u.UserId == user.Id && u.ActivityId == actId).FirstOrDefault(); List <Guest> otherlinks = _context.Links.Where(u => u.UserId == user.Id).Include(l => l.Activity).ToList(); foreach (var link in otherlinks) { if (link.Activity.Date == activity.Date && link.Activity.Time == activity.Time) { TempData["Conflict"] = "Can't have activities at same time"; return(RedirectToAction("Home")); } if (link.Activity.Date == activity.Date) { var existinghour1 = link.Activity.Time.Split(':').First(); var existingminute1 = link.Activity.Time.Split(':')[1]; var existinghour = Int32.Parse(existinghour1); var existingminute = Int32.Parse(existingminute1); var tryhour1 = activity.Time.Split(':').First(); var tryminute1 = activity.Time.Split(':')[1]; var tryhour = Int32.Parse(tryhour1); var tryminute = Int32.Parse(tryminute1); if (existinghour > tryhour && existinghour <= tryhour + activity.Duration && activity.Units == "Hours") { TempData["Conflict"] = "Can't have activities at same time"; return(RedirectToAction("Home")); } else if (existinghour == tryhour) { if (existinghour + link.Activity.Duration < tryhour + activity.Duration && link.Activity.Units == "Hours" && activity.Units == "Hours") { TempData["Conflict"] = "Can't have activities at same time"; return(RedirectToAction("Home")); } else { TempData["Conflict"] = "Can't have activities at same time"; return(RedirectToAction("Home")); } } } } if (existinglink != null) { TempData["AlreadyRSVP"] = "You have already RSVPd to this event"; return(RedirectToAction("Home")); } else { Guest newguest = new Guest() { User = user, Activity = activity, UserId = user.Id, ActivityId = activity.ActivityId, }; System.Console.WriteLine("activity id"); System.Console.WriteLine(activity.ActivityId); System.Console.WriteLine("link activity id"); System.Console.WriteLine(newguest.ActivityId); user.ActivitiesAttending.Add(newguest); _context.Links.Add(newguest); _context.SaveChanges(); return(RedirectToAction("Home")); } }
private static bool ForEachEventCallback(ref TState state, ActivityEvent item) => state.ForEach(item);
private void EndPeriod() { Fire(_currentEvent); _currentEvent = null; }
private bool IsEmptyWindowRequired(ActivityEvent @event) { return(_currentWindow.IsOnSameDayAs(@event)); }
private static bool ProcessActivityEvents(ref PooledList <ZipkinAnnotation> annotations, ActivityEvent @event) { PooledList <ZipkinAnnotation> .Add(ref annotations, new ZipkinAnnotation(@event.Timestamp.ToEpochMicroseconds(), @event.Name)); return(true); }
void OnDestroy() { ActivityEventOk = null; }
} // Train involved in event; if null actual or original player train protected EventWrapper(ActivityEvent activityEvent) { ActivityEvent = activityEvent; Train = null; }
private static bool ProcessActivityEvent(ref PooledListState <JaegerLog> state, ActivityEvent e) { if (!state.Created) { state.List = PooledList <JaegerLog> .Create(); state.Created = true; } PooledList <JaegerLog> .Add(ref state.List, e.ToJaegerLog()); return(true); }
public ActivityEventMessage(ActivityEvent activityEvent) { this.ActivityEvent = activityEvent; }
public static void EnumerateTags <T>(this ActivityEvent activityEvent, ref T tagEnumerator) where T : struct, IActivityEnumerator <KeyValuePair <string, object> > { ActivityTagsEnumeratorFactory <T> .Enumerate(activityEvent, ref tagEnumerator); }
private bool FirstQueuedEventStartsBefore(ActivityEvent @event) { return(_queue.Any() && _queue.Peek().GetTriggeredAt() < @event.GetTriggeredAt()); }
public async Task Send(ActivityEvent activityEvent) { var message = new ActivityEventMessage(activityEvent); var jsonMessage = JsonConvert.SerializeObject(message, jsonSerializerSettings); Debug.WriteLine("Send Activity-Event To Multiplayer-Server", jsonMessage); await Send(jsonMessage); }
public async Task Send (ActivityEvent input) { string message = JsonConvert.SerializeObject (input, jsonSerializerSettings); await Send (message); }
private Window CreateWindowStartingAt(ActivityEvent @event) { return(new Window(@event.GetTriggeredAt(), _windowSpan)); }
internal static ActivityState FromPlugin(this ActivityEvent @event) => (ActivityState)Enum.Parse(typeof(ActivityState), @event.ToString(), true);