Esempio n. 1
0
            private void SetState(ElectStateContext context, MonitorJobStatusDto dto)
            {
                var actionName = context.BackgroundJob.Job.Method.GetFullActionName();
                var key        = context.Connection.GetMonitorStateKey(DateTime.Today, actionName);

                context.Connection.SetMonitorState(key, dto);
            }
Esempio n. 2
0
            void IElectStateFilter.OnStateElection(ElectStateContext context)
            {
                if (context.CandidateState is SucceededState succeededstate)
                {
                    var isValid = Validate();

                    var dto = new MonitorJobStatusDto
                    {
                        Status        = isValid ? MonitorJobStatus.Successed : MonitorJobStatus.Invalid,
                        ExecutedTime  = DateTime.UtcNow,
                        ExecutedJobId = context.BackgroundJob.Id
                    };

                    SetState(context, dto);
                }
                else if (context.CandidateState is FailedState state)
                {
                    SetState(context, new MonitorJobStatusDto(MonitorJobStatus.Failed));
                }
            }