/// <summary> /// 添加事件 /// </summary> public void AddEvent(float delay, int id, Action <int> method) { LineEvent param = new LineEvent(delay, id, method); m_update += param.Invoke; m_Reset += param.Reset; }
/// <summary>Constructs a new event of the specified type, originating from the specified line. /// </summary> /// <remarks>Constructs a new event of the specified type, originating from the specified line. /// </remarks> /// <param name="line">the source of this event</param> /// <param name="type">the event type (<code>OPEN</code>, <code>CLOSE</code>, <code>START</code>, or <code>STOP</code>) /// </param> /// <param name="position"> /// the number of sample frames that the line had already processed when the event occurred, /// or /// <see cref="AudioSystem.NOT_SPECIFIED">AudioSystem.NOT_SPECIFIED</see> /// </param> /// <exception cref="System.ArgumentException"> /// if <code>line</code> is /// <code>null</code>. /// </exception> public LineEvent(Line line, LineEvent.Type type, long position) : base(line) { // INSTANCE VARIABLES this.type = type; this.position = position; }
/// <summary> /// Basic Echo Robot /// </summary> /// <param name="ev"></param> /// <returns></returns> protected override async Task OnMessageAsync(LineEvent ev) { if (ev.Message.Type.Equals(LineMessageType.text)) { await _lineMessageService.ReplyMessageAsync(ev.ReplyToken, ev.Message.Text); } }
public bool Overlaps(LineEvent other) { if (LineID != other.LineID) { return(false); } return(TimeRange.Overlaps(other.TimeRange)); }
protected override async Task OnBeaconAsync(LineEvent ev) { if (_settings.CurrentValue.Beacon.Enabled && ev.beacon.type == BeaconType.enter) { var userProfile = await _lineMessageUtility.GetUserProfile(ev.source.userId).ConfigureAwait(false); await _lineMessageUtility.ReplyMessageAsync(ev.replyToken, $"歡迎蒞臨\r\n{userProfile.displayName}").ConfigureAwait(false); } }
public bool Contains(LineEvent other) { if (LineID != other.LineID) { return(false); } return(TimeRange.Contains(other.TimeRange)); }
private static void DequeueLineEvent(LineEvent lineEvent) { EmailProcessingThread.Push(() => { if (QueuedLineEvents.Remove(lineEvent)) { GenerateEmail(lineEvent); } }); }
public void RemoveIsectEvent(LineSegment s1, LineSegment s2, Vector3 p) { LineEvent e1 = new LineEvent(p, s1); LineEvent e2 = new LineEvent(p, s2); if (mCompareLines.CurrentX < p.x) { return; } mEventQ.Remove(e1); mEventQ.Remove(e2); }
public LineEvent Merge(LineEvent other) { if (LineID != other.LineID) { throw new ArgumentException("Unable to merge line events on separate lines.", nameof(other)); } Range <DateTime> mergedTimeRange = TimeRange.Merge(other.TimeRange); DateTime timeCreated = Common.Min(TimeCreated, other.TimeCreated); DateTime timeUpdated = Common.Max(TimeUpdated, other.TimeUpdated); return(new LineEvent(LineID, mergedTimeRange, timeCreated, timeUpdated)); }
private static LineEvent MergeWithDatabase(LineEvent lineEvent) { const string MinStartTimeFormat = "SELECT MIN(StartTime) FROM Event WHERE LineID = {0} AND {1} BETWEEN StartTime AND EndTime"; const string MaxEndTimeFormat = "SELECT MAX(EndTime) FROM Event WHERE LineID = {0} AND {1} BETWEEN StartTime AND EndTime"; Func <LineEvent, LineEvent, LineEvent> merge = (lineEvent1, lineEvent2) => lineEvent1.Merge(lineEvent2); DateTime startTime = lineEvent.TimeRange.Start; DateTime endTime = lineEvent.TimeRange.End; using (AdoDataConnection connection = s_connectionFactory()) { while (true) { DateTime adjustedStartTime = startTime.AddSeconds(-s_timeTolerance); object adjustedStartTime2 = ToDateTime2(connection, adjustedStartTime); DateTime minStartTime = connection.ExecuteScalar(startTime, MinStartTimeFormat, lineEvent.LineID, adjustedStartTime2); if (startTime == minStartTime) { break; } startTime = minStartTime; } while (true) { DateTime adjustedEndTime = endTime.AddSeconds(s_timeTolerance); object adjustedEndTime2 = ToDateTime2(connection, adjustedEndTime); DateTime maxEndTime = connection.ExecuteScalar(endTime, MaxEndTimeFormat, lineEvent.LineID, adjustedEndTime2); if (endTime == maxEndTime) { break; } endTime = maxEndTime; } } if (startTime == lineEvent.TimeRange.Start && endTime == lineEvent.TimeRange.End) { return(lineEvent); } Range <DateTime> dbTimeRange = new Range <DateTime>(startTime, endTime); LineEvent dbLineEvent = new LineEvent(lineEvent.LineID, dbTimeRange); return(lineEvent.Merge(dbLineEvent)); }
public void InitServiceData(LineEvent lineEvent) { //Set reply token _replyToken = lineEvent.ReplyToken; //Set type _type = lineEvent.Type; //Set source type and chat id(room id, group id, user id) SetChatData(lineEvent.Source); //Set message _message = lineEvent.Message; }
private static LineEvent MergeWithRecentLineEvents(LineEvent lineEvent) { Func <LineEvent, LineEvent, LineEvent> merge = (lineEvent1, lineEvent2) => lineEvent1.Merge(lineEvent2); List <LineEvent> overlappingEvents = RecentLineEvents .Where(recentLineEvent => recentLineEvent.Overlaps(lineEvent)) .ToList(); LineEvent mergedLineEvent = overlappingEvents.Aggregate(lineEvent, merge); RecentLineEvents.ExceptWith(overlappingEvents); RecentLineEvents.Add(mergedLineEvent); return(mergedLineEvent); }
private static bool QueueLineEvent(LineEvent lineEvent) { DateTime now = DateTime.UtcNow; DateTime maxDequeueTime = lineEvent.TimeCreated + s_maxWaitPeriod; DateTime minDequeueTime = lineEvent.TimeUpdated + s_minWaitPeriod; DateTime dequeueTime = Common.Min(maxDequeueTime, minDequeueTime); if (now < dequeueTime) { TimeSpan delaySpan = dequeueTime - now; int delay = (int)Math.Ceiling(delaySpan.TotalMilliseconds); QueuedLineEvents.Add(lineEvent); new Action(() => DequeueLineEvent(lineEvent)).DelayAndExecute(delay); return(true); } return(false); }
private static void GenerateEmail(LineEvent lineEvent) { using (AdoDataConnection connection = s_connectionFactory()) { TableOperations <Event> eventTable = new TableOperations <Event>(connection); object startTime2 = ToDateTime2(connection, lineEvent.TimeRange.Start); object endTime2 = ToDateTime2(connection, lineEvent.TimeRange.End); RecordRestriction recordRestriction = new RecordRestriction("LineID = {0}", lineEvent.LineID) & new RecordRestriction("StartTime >= {0}", startTime2) & new RecordRestriction("EndTime <= {0}", endTime2); Event evt = eventTable.QueryRecord(recordRestriction); GenerateEmail(connection, evt.ID); } }
private static void QueueEvent(Event evt) { LineEvent lineEvent = new LineEvent(evt); EmailProcessingThread.Push(() => { if (!RecentLineEvents.Any()) { QueryRecentLineEvents(); } List <LineEvent> overlappingLineEvents = QueuedLineEvents .Where(queuedLineEvent => lineEvent.Overlaps(queuedLineEvent)) .ToList(); if (overlappingLineEvents.Any()) { QueuedLineEvents.ExceptWith(overlappingLineEvents); lineEvent = overlappingLineEvents.Aggregate(lineEvent, (mergedLineEvent, queuedLineEvent) => mergedLineEvent.Merge(queuedLineEvent)); } else { DateTime twoDaysAgo = DateTime.UtcNow.AddDays(-2.0D); if (lineEvent.TimeRange.End > twoDaysAgo) { lineEvent = MergeWithRecentLineEvents(lineEvent); } if (lineEvent.TimeRange.Start < twoDaysAgo) { lineEvent = MergeWithDatabase(lineEvent); } } if (!QueueLineEvent(lineEvent)) { GenerateEmail(lineEvent); } }); }
public List <LineSegment> CollectLines(LineEvent e) { List <LineSegment> collected = new List <LineSegment>(); LineEvent nextEvent = e; VecCompare vcompare = new VecCompare(); int order = 0; while (order == 0) { collected.Add(nextEvent.Line); mEventQ.Remove(nextEvent); nextEvent = mEventQ.Min; if (nextEvent != null) { order = vcompare.Compare(nextEvent.Point, e.Point); } else { break; } } return(collected); }
private static void QueryRecentLineEvents() { using (AdoDataConnection connection = s_connectionFactory()) { TableOperations <Event> eventTable = new TableOperations <Event>(connection); DateTime twoDaysAgo = DateTime.UtcNow.AddDays(-2.0D); object twoDaysAgo2 = ToDateTime2(connection, twoDaysAgo); List <Event> recentEvents = eventTable.QueryRecordsWhere("EndTime >= {0}", twoDaysAgo2).ToList(); foreach (IGrouping <int, Event> grouping in recentEvents.GroupBy(evt => evt.LineID)) { LineEvent mergedLineEvent = null; foreach (Event evt in grouping) { LineEvent lineEvent = new LineEvent(evt); if ((object)mergedLineEvent == null) { mergedLineEvent = lineEvent; } if (!mergedLineEvent.Overlaps(lineEvent)) { RecentLineEvents.Add(mergedLineEvent); mergedLineEvent = lineEvent; } mergedLineEvent = mergedLineEvent.Merge(lineEvent); } RecentLineEvents.Add(mergedLineEvent); } } PurgeOldLineEventsAction.DelayAndExecute(PurgeInterval); }
public void AddLines(List <LineSegment> lines) { try { foreach (LineSegment line in lines) { LineEvent p1 = new LineEvent(line.Start, line); LineEvent p2 = new LineEvent(line.End, line); line.VertexIndex = -1; mEventQ.Add(p1); mEventQ.Add(p2); if (mLineMesh != null) { Color c = new Color(Random.value, Random.value, Random.value, 1); line.VertexIndex = mLineMesh.Add(line, c); } } } catch (ArgumentException ex) { Debug.LogWarning(ex.Message); } }
protected override async Task OnMessageAsync(LineEvent ev) { // Get Line User Profile var lineUser = await _lineMessageUtility.GetUserProfile(ev.source.userId); var request = new MessageRequestDTO() { Intent = ev.message.Text, Message = ev.message.Text, UserId = ev.source.userId, DisplayName = lineUser.displayName, IsFromGroup = ev.source.type == "group", PostbackParams = ev.postback?.@params }; if (ev.message.Type == NetCoreLineBotSDK.Enums.LineMessageType.Text) { var providers = await _factory.GetProvidersAsync(request); var replyMessages = await providers.GetReplyMessagesAsync(); await _lineMessageUtility.ReplyMessageAsync(ev.replyToken, replyMessages); } }
protected virtual Task OnUnfollowAsync(LineEvent ev) => Task.CompletedTask;
protected virtual Task OnMessageAsync(LineEvent ev) => Task.CompletedTask;
protected override async Task OnPostbackAsync(LineEvent ev) { var postback = JsonConvert.SerializeObject(ev); await _lineMessageUtility.ReplyMessageAsync(ev.replyToken, postback); }
protected override async Task OnMessageAsync(LineEvent ev) { await _lineMessageUtility.ReplyMessageAsync(ev.replyToken, $"You Said:{ev.message.Text}"); }
public bool Process(LineEnumerator lineiter) { if (mEventQ.Count == 0) { return(false); } LineEvent e = mEventQ.Min; Vector3 isect = new Vector3(); LineSegment bottomNeighbor; LineSegment topNeighbor; float curX = e.Point.x; List <LineSegment> collected = CollectLines(e); if (collected.Count > 1) { MarkIntersection(e.Point); } for (int i = 0; i < collected.Count; ++i) { LineSegment l = collected[i]; if (l.End == e.Point) { RemoveActive(l); collected.RemoveAt(i); } } if (collected.Count == 0) { mCompareLines.CurrentX = curX; bottomNeighbor = lineiter.FindBottomNeighbor(e.Line); topNeighbor = lineiter.FindTopNeighbor(e.Line); if ((bottomNeighbor != null) && (topNeighbor != null) && (bottomNeighbor.FindIntersection(topNeighbor, ref isect) > 0)) { AddIsectEvent(bottomNeighbor, topNeighbor, isect); } } else { foreach (LineSegment l in collected) { RemoveActive(l); } mCompareLines.CurrentX = curX; foreach (LineSegment l in collected) { AddActive(l); } LineSegment bottom = collected[0]; LineSegment top = collected[collected.Count - 1]; bottomNeighbor = lineiter.FindBottomNeighbor(bottom); topNeighbor = lineiter.FindTopNeighbor(top); if ((bottomNeighbor != null) && (bottomNeighbor.FindIntersection(bottom, ref isect) > 0)) { AddIsectEvent(bottomNeighbor, bottom, isect); } if ((topNeighbor != null) && (topNeighbor.FindIntersection(top, ref isect) > 0)) { AddIsectEvent(top, topNeighbor, isect); if ((bottomNeighbor != null) && (bottomNeighbor.FindIntersection(topNeighbor, ref isect) > 0)) { RemoveIsectEvent(bottomNeighbor, topNeighbor, isect); } } } return(true); }
private async Task LoadEventAsync() { // loading model model = new LineEvent(); }
public void update(LineEvent lineEvent) { Microphone.access_000(this.this_0).info(new StringBuilder().append("line listener ").append(lineEvent).toString()); }
protected virtual Task OnUnPostbackAsync(LineEvent ev) => Task.CompletedTask;
protected virtual Task OnBeaconAsync(LineEvent ev) => Task.CompletedTask;
protected override Task OnFollowAsync(LineEvent ev) { return(base.OnFollowAsync(ev)); }