private Event CreateObject() { Event obj = new Event(); obj.CheckStatus = CheckStatus.Default; obj.Description = "An account has been activated."; obj.Guid = Guid.Parse("22a1d55d-2feb-4f5f-93d3-56658772a700"); obj.VersionId = Guid.Parse("22a1d55d-2feb-4f5f-93d3-56658772a700"); obj.Name = "AccountActivatedEvent"; obj.IsPublic = false; obj.InternalName = "Mecalux.ITSW.EasyWMS.Modules.MasterData.Contracts.Events.AccountActivatedEvent, Mecalux.ITSW.EasyWMS.Modules.Contracts"; EventProperty p1 = new EventProperty(); p1.DataType = EventPropertyDataType.NullableGuid; p1.Description = "Gets or sets the carrier identifier"; p1.Name = "AgencyId"; obj.AddEventProperty(p1); EventProperty p2 = new EventProperty(); p2.DataType = EventPropertyDataType.Guid; p2.Name = "SourceId"; obj.AddEventProperty(p2); return(obj); }
public Job Mutate <TSource>(Job job, JobStatus?status = null, int?dispatchCount = null, DateTime?retryOn = null, Continuation continuation = null, bool?suspended = null) { var newJob = new Job(job.Id, job.Type, job.Method, job.Arguments, job.CreatedOn, job.RootId, job.ParentId, job.CorrelationId, status ?? job.Status, dispatchCount ?? job.DispatchCount, retryOn ?? job.RetryOn, job.ExceptionFilters, continuation ?? job.Continuation, suspended ?? job.Suspended); _repository.Store(newJob); if (job.Status != newJob.Status) { _eventStream.Publish <TSource>( EventType.JobStatusChanged, EventProperty.JobSnapshot(job), EventProperty.FromStatus(job.Status), EventProperty.ToStatus(newJob.Status)); } return(newJob); }
EventProperty[] ConstructNamedProperties(MessageTemplate template, object[] messageTemplateParameters) { var namedProperties = template.NamedProperties; if (namedProperties == null) { return(NoProperties); } var matchedRun = namedProperties.Length; if (namedProperties.Length != messageTemplateParameters.Length) { matchedRun = Math.Min(namedProperties.Length, messageTemplateParameters.Length); SelfLog.WriteLine("Named property count does not match parameter count: {0}", template); } var result = new EventProperty[messageTemplateParameters.Length]; for (var i = 0; i < matchedRun; ++i) { var property = template.NamedProperties[i]; var value = messageTemplateParameters[i]; result[i] = ConstructProperty(property, value); } for (var i = matchedRun; i < messageTemplateParameters.Length; ++i) { var value = _valueConverter.CreatePropertyValue(messageTemplateParameters[i]); result[i] = new EventProperty("__" + i, value); } return(result); }
void ProcessAll(Guid id, ConcurrentQueue <CoordinationRequest> q) { _eventStream.Publish <JobCoordinator>(EventType.Activity, EventProperty.ActivityName("CoordinatedEventProcessingCycleStarted")); while (true) { CoordinationRequest request; if (q.TryDequeue(out request)) { _recoverableAction.Run(request.Action, () => Run(request.Job, request.Action)); } else { lock (_latch) { if (q.IsEmpty) { _coordinationQueues.Remove(id); break; } } } } _eventStream.Publish <JobCoordinator>(EventType.Activity, EventProperty.ActivityName("CoordinatedEventProcessingCycleFinished")); }
/// <summary> /// Takes an event record, and writes the properties into a string builder. /// This assumes that the event is a .Net Runtime Provider EventID 1026, which only has one property /// that is a Crash Report for Visual Studio. /// </summary> /// <param name="events">StringBuilder to write the properties to.</param> /// <param name="eventLogEntry">EventRecord to extract properties from</param> private void WriteCrashReport(StringBuilder events, EventRecord eventLogEntry) { if (eventLogEntry == null) { return; } // We assume that this .Net Runtime Provider EventID 1026, which only has one property EventProperty eventProperty = eventLogEntry.Properties.FirstOrDefault(); if (eventProperty != null) { int stringBuildInitialLength = events.Length; if (eventLogEntry.TimeCreated.HasValue) { events.Append("Event Log Time: "); events.AppendLine(eventLogEntry.TimeCreated.Value.ToLocalTime().ToString()); } String crashReport = eventProperty.Value.ToString(); crashReport = crashReport.Replace(" at ", Environment.NewLine + " at "); crashReport = crashReport.Replace("Framework Version:", Environment.NewLine + "Framework Version:"); crashReport = crashReport.Replace("Description:", Environment.NewLine + "Description:"); crashReport = crashReport.Replace("Exception Info:", Environment.NewLine + "Exception Info:" + Environment.NewLine); crashReport = crashReport.Replace("Stack:", Environment.NewLine + "Stack:"); events.AppendLine(crashReport); } }
public void Write(Job job) { var suspendedCount = 0; var suspended = false; lock (_queueAccess) { if (_reader != null && _reader.TrySetResult(job)) { return; } // Suspend if this is not the default job queue and this is currently overlfowed. if ((_suspendedCount > 0 || _items.Count >= Configuration.MaxQueueLength)) { _suspendedCount++; suspended = true; suspendedCount = _suspendedCount; } else { _items.Enqueue(job); } } if (!suspended) { return; } _recoverableAction.Run(() => _jobMutator.Mutate <JobQueue>(job, suspended: true)); _eventStream.Publish <JobQueue>(EventType.JobSuspended, EventProperty.JobSnapshot(job), EventProperty.Named("SuspendedCount", suspendedCount)); }
public static void AddAction(string key, string text = null, Dictionary <string, Parameter> prms = null) { actions[key] = new EventProperty(key, text) { type = EventProperty.TYPE.ACTION, parameters = prms }; }
public void Add(Job job) { _eventStream.Publish <FailedJobQueue>( EventType.Activity, EventProperty.ActivityName("NewFailedItem"), EventProperty.JobSnapshot(job)); _jobFailures.Add(Tuple.Create(job.Id, job.RetryOn)); }
void PublishQueueInitializedEvent(int activityCount, int suspendedCount, Type activityType = null) { _eventStream.Publish <JobQueueFactory>( EventType.Activity, EventProperty.ActivityName("JobQueueInitialized"), EventProperty.Named("ActivityType", activityType == null ? "All" : activityType.FullName), EventProperty.Named("ActivityCount", activityCount), EventProperty.Named("SuspendedCount", suspendedCount)); }
public void OnClickAddAction(string act = null) { EventProperty prop = GameData.actions[act ?? action_dropdown.options[action_dropdown.value].text]; GameObject new_item = Instantiate(prop_prefab); CondActItem new_item_script = new_item.GetComponent <CondActItem>(); new_item_script.prop = prop; new_item_script.trigger = trigger; new_item.transform.SetParent(actions_container.transform); }
/// <summary> /// 添加EventProperty,若包含已有TypeID则返回错误。 /// </summary> /// <param name="eventPro"></param> /// <returns></returns> public bool AddEventProcess(EventProperty <FlowGather> eventPro) { //首先检测是否含有指定的TypID if (eventList.Find(x => x.TypeID == eventPro.TypeID) == null) { eventList.Add(eventPro); return(true); } return(false); }
/// <summary> /// TODO The crete json event configuration template. /// </summary> /// <param name="eventObject"> /// TODO The bubbling event. /// </param> /// <returns> /// The <see cref="string" />. /// </returns> public static string CreteJsonEventConfigurationTemplate(IEventAssembly eventObject) { try { var eventConfiguration = new EventConfiguration(); eventConfiguration.Event = new Event( eventObject.Id, "{Configuration ID to execute}", eventObject.Name, eventObject.Description); eventConfiguration.Event.EventProperties = new List <EventProperty>(); foreach (var Property in eventObject.Properties) { if (Property.Value.Name != "DataContext") { var eventProperty = new EventProperty(Property.Value.Name, "Value to set"); eventConfiguration.Event.EventProperties.Add(eventProperty); } } var eventCorrelationTemplate = new Event( "{Event component ID to execute if Correlation = true}", "{Configuration ID to execute if Correlation = true}", "EventName", "EventDescription"); eventCorrelationTemplate.Channels = new List <Channel>(); var points = new List <Point>(); points.Add(new Point("Point ID", "Point Name", "Point Description")); eventCorrelationTemplate.Channels.Add( new Channel("Channel ID", "Channel Name", "Channel Description", points)); var events = new List <Event>(); events.Add(eventCorrelationTemplate); eventConfiguration.Event.Channels = new List <Channel>(); eventConfiguration.Event.Channels.Add( new Channel("Channel ID", "Channel Name", "Channel Description", points)); eventConfiguration.Event.Correlation = new Correlation("Correlation Name", "C# script", events); var serializedMessage = JsonConvert.SerializeObject( eventConfiguration, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return(serializedMessage); // return "<![CDATA[" + serializedMessage + "]]>"; } catch (Exception ex) { return(ex.Message); } }
void OnTick(object state) { var ready = new Collection <Tuple <Guid, DateTime?> >(); var notReady = new Collection <Tuple <Guid, DateTime?> >(); try { Tuple <Guid, DateTime?> item; _eventStream.Publish <FailedJobQueue>( EventType.TimerActivity, EventProperty.ActivityName("RescheduleFailedJobs"), EventProperty.Named("FailedItemsQueueLength", _jobFailures.Count)); while (_jobFailures.TryTake(out item)) { if (item.Item2 < _now()) { ready.Add(item); } else { notReady.Add(item); } } foreach (var job in ready.Select(i => _persistenceStore.Load(i.Item1))) { _router.Route(job); } ready.Clear(); } catch (Exception e) { if (e.IsFatal()) { throw; } _eventStream.Publish <FailedJobQueue>(e); } finally { foreach (var item in ready.Concat(notReady)) { _jobFailures.Add(item); } _timer.Change(_configuration.RetryTimerInterval, Timeout.InfiniteTimeSpan); } }
public static ExtentionPropertyDto GetExtentionProperty(EventProperty property) { if (property == null) { return(null); } return(new ExtentionPropertyDto() { Name = property.Name, Value = property.Value, Type = property.DataType }); }
public float this[EventProperty index] { get { float value; _eventInstance.getProperty((EVENT_PROPERTY)index, out value).Check(); return(value); } set { _eventInstance.setProperty((EVENT_PROPERTY)index, value); } }
public EventProperty.CallbackType?CheckEvent(EventProperty eventProperty, float percentage) { if (eventProperty == null) { Debug.LogWarning("EventProperty is null, maybe something went wrong at the initialization? Event will not be fired"); return(null); } ClampValues(ref EventPercentage.x); ClampValues(ref EventPercentage.y); float minVal = EventPercentage.y < EventPercentage.x ? EventPercentage.y : EventPercentage.x; float maxVal = EventPercentage.x < EventPercentage.y ? EventPercentage.y : EventPercentage.x; return(EventToFire(percentage, minVal, maxVal)); }
EventProperty[] ConstructPositionalProperties(MessageTemplate template, object[] messageTemplateParameters) { var positionalProperties = template.PositionalProperties; if (positionalProperties.Length != messageTemplateParameters.Length) { SelfLog.WriteLine("Positional property count does not match parameter count: {0}", template); } var result = new EventProperty[messageTemplateParameters.Length]; foreach (var property in positionalProperties) { if (property.TryGetPositionalValue(out var position)) { if (position < 0 || position >= messageTemplateParameters.Length) { SelfLog.WriteLine("Unassigned positional value {0} in: {1}", position, template); } else { result[position] = ConstructProperty(property, messageTemplateParameters[position]); } } } var next = 0; for (var i = 0; i < result.Length; ++i) { if (!result[i].Equals(EventProperty.None)) { result[next] = result[i]; ++next; } } if (next != result.Length) { Array.Resize(ref result, next); } return(result); }
async Task <Job[]> LoadSuspended() { var list = new List <Job>(); while (list.Count == 0) { try { var max = Configuration.MaxQueueLength; var items = (Configuration.Type != null ? _persistenceStore.LoadSuspended(Configuration.Type, max) : _persistenceStore.LoadSuspended(_allActivityConfiguration.Select(c => c.Type), max)) .ToArray(); _eventStream.Publish <JobQueue>(EventType.Activity, EventProperty.ActivityName("LoadSuspendedItemsStarted"), EventProperty.Named("NumberOfItems", items.Length)); list.AddRange(items.Select(item => _jobMutator.Mutate <JobQueue>(item, suspended: false))); } catch (Exception e) { if (e.IsFatal()) { throw; } _eventStream.Publish <JobQueue>(e); } if (!list.Any()) { await Task.Delay(Configuration.RetryDelay); } } _eventStream.Publish <JobQueue>(EventType.Activity, EventProperty.ActivityName("LoadSuspendedItemsFinished"), EventProperty.Named("NumberOfItems", list.Count)); return(list.ToArray()); }
public static EventData Build(object evt) { Type eventType = evt.GetType(); EventData eventData = new EventData(); TypeReflectionInfoProvider.TypeReflectionInfo reflectionInfo = TypeReflectionInfoProvider.GetReflectionInfo(eventType); List <EventProperty> properties = new List <EventProperty>(); foreach (FieldInfo fieldInfo in reflectionInfo.Fields) { properties.Add(EventProperty.Build(fieldInfo.Name, fieldInfo.GetValue(evt))); } foreach (PropertyInfo propertyInfo in reflectionInfo.Properties) { properties.Add(EventProperty.Build(propertyInfo.Name, propertyInfo.GetValue(evt, null))); } eventData.EventProperties = properties.ToArray(); StringBuilder nameBuilder = new StringBuilder(); nameBuilder.Append(eventType.FullName); if (properties.Count > 0) { nameBuilder.Append(" ("); for (int i = 0; i < properties.Count; i++) { EventProperty eventProperty = properties[i]; nameBuilder.AppendFormat("{0}: {1}", eventProperty.Name, eventProperty.StringValue); if (i != properties.Count - 1) { nameBuilder.Append(", "); } } nameBuilder.Append(" )"); } eventData.EventTypeName = nameBuilder.ToString(); return(eventData); }
// Token: 0x0600014D RID: 333 RVA: 0x00007674 File Offset: 0x00005874 internal T Get <T>(EventRecordParameteIndex index) { if (index > (EventRecordParameteIndex)(this.propertiesCount - 1)) { throw new InvalidFailureItemException(string.Format("index {0} is out of range (max={1})", (int)index, this.propertiesCount)); } EventProperty eventProperty = this.properties[(int)index]; if (eventProperty == null) { throw new InvalidFailureItemException(string.Format("property# {0} is null", index)); } object value = eventProperty.Value; if (value == null) { throw new InvalidFailureItemException(string.Format("property value# {0} is null", index)); } return((T)((object)value)); }
/// <summary> /// 等待控制流 /// </summary> /// <param name="fgNow">当前处理步骤</param> /// <param name="fgNext">下一步骤处理</param> private void WaitOne(FlowGather fgNow, FlowGather fgNext) { var m = new EventProperty <FlowGather>(fgNow); eventControlFlow.RemoveEventProcess(fgNext); eventControlFlow.AddEventProcess(m); while (true) { if (m.Event.WaitOne(new TimeSpan(0, 0, 0, 0, 20))) { eventControlFlow.RemoveEventProcess(fgNow); FlowStep = fgNext; break; } if (!IsRunState) { FlowStep = FlowGather.Leisure; break; } } }
void OnTick(object state) { try { var maxItemsToRetry = _itemsToRecover.Count; _eventStream.Publish <RecoverableAction>( EventType.TimerActivity, EventProperty.ActivityName("RecoveryTimer"), new KeyValuePair <string, object>( "NumberOfItemsToProcess", maxItemsToRetry)); for (var i = 0; i < maxItemsToRetry; i++) { RecoverableActionRequest request; if (!_itemsToRecover.TryDequeue(out request)) { break; } Task.Run(() => RunCore(request)).FailFastOnException(); } } catch (Exception e) { if (e.IsFatal()) { throw; } _eventStream.Publish <RecoverableAction>(e); } finally { _timer.Change(_configuration.RetryTimerInterval, Timeout.InfiniteTimeSpan); } }
public static EventProperty Build(string name, object value) { EventProperty eventProperty = new EventProperty(); eventProperty.Name = name; if (value == null) { eventProperty.StringValue = "null"; } else { eventProperty.Object = value; Object unityObject = value as Object; if (unityObject != null) { eventProperty.UnityObject = unityObject; } eventProperty.StringValue = value.ToString(); } return(eventProperty); }
set => this.SetValue(EventProperty, value);
public virtual void Visit(EventProperty ep) { }
private async void Button_OnClick(object sender, RoutedEventArgs e) { List <Light> allLights; try { allLights = (await MainWindowViewModel.Client.GetLightsAsync()).ToList(); } catch { allLights = null; } if (ViewModel.MainWindowViewModel.GlobalLightsBackup == null) { ViewModel.MainWindowViewModel.GlobalLightsBackup = allLights; } var unreachableLights = new List <Light>(); if (allLights != null) { foreach (var l in allLights) { if (l.State.IsReachable != true) { unreachableLights.Add(l); } } } foreach (var l in unreachableLights) { if (l.State.IsReachable != true) { allLights?.Remove(l); } } if (allLights == null || !allLights.Any()) { new CustomMessageBox { Button1 = new CustomButton { Text = Cultures.Resources.OkButton }, Message = Cultures.Resources.NoLightsFoundMessage, Owner = Window.GetWindow(this) }.ShowDialog(); return; } var title = Cultures.Resources.LightSelectorTitle + " - "; EventProperty property = null; EventBrightnessProperty brightnessProperty = null; if (((Button)sender).Tag.ToString() == "MainMenu") { title += Cultures.Resources.MainMenuEvent; property = Properties.Settings.Default.MainMenu; } if (((Button)sender).Tag.ToString() == "PlayerGetsFlashed") { title += Cultures.Resources.PlayerGetsFlashedEvent; property = Properties.Settings.Default.PlayerGetsFlashed; } if (((Button)sender).Tag.ToString() == "TerroristsWin") { title += Cultures.Resources.TerroristsWinEvent; property = Properties.Settings.Default.TerroristsWin; } if (((Button)sender).Tag.ToString() == "CounterTerroristsWin") { title += Cultures.Resources.CounterTerroristsWinEvent; property = Properties.Settings.Default.CounterTerroristsWin; } if (((Button)sender).Tag.ToString() == "RoundStarts") { title += Cultures.Resources.RoundStartsEvent; property = Properties.Settings.Default.RoundStarts; } if (((Button)sender).Tag.ToString() == "BombPlanted") { title += Cultures.Resources.BombHasBeenPlantedEvent; property = Properties.Settings.Default.BombPlanted; } if (((Button)sender).Tag.ToString() == "PlayerGetsKill") { title += Cultures.Resources.PlayerGetsAKillEvent; brightnessProperty = Properties.Settings.Default.PlayerGetsKill; } if (((Button)sender).Tag.ToString() == "PlayerGetsKilled") { title += Cultures.Resources.PlayerGetsKilledEvent; brightnessProperty = Properties.Settings.Default.PlayerGetsKilled; } if (((Button)sender).Tag.ToString() == "FreezeTime") { title += Cultures.Resources.FreezeTimeEvent; brightnessProperty = Properties.Settings.Default.FreezeTime; } if (((Button)sender).Tag.ToString() == "Warmup") { title += Cultures.Resources.WarmupEvent; brightnessProperty = Properties.Settings.Default.Warmup; } if (((Button)sender).Tag.ToString() == "BombExplodes") { title += Cultures.Resources.BombExplodesEvent; brightnessProperty = Properties.Settings.Default.BombExplodes; } if (((Button)sender).Tag.ToString() == "BombBlink") { title += Cultures.Resources.BombBlinkEvent; brightnessProperty = Properties.Settings.Default.BombBlink; } ViewModel.LightsBackup = allLights; new LightSelector(title) { AllLights = allLights, Property = property, BrightnessProperty = brightnessProperty, Owner = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault() }.ShowDialog(); ViewModel.RestoreLights(); ViewModel.MainWindowViewModel.Settings.ViewModel.UpdateGradients(); Save(sender, e); }
set => SetValue(EventProperty, value);
public TestUIModel() { // From g-InputField@input->money:string money = new EventProperty <string>(() => { return(testValue); }, (x) => { testValue = x; }); }
get => (string)GetValue(EventProperty); set { SetValue(EventProperty, value); }
get => (TraceEvent)GetValue(EventProperty); set => SetValue(EventProperty, value);