示例#1
0
        // forceEmail set to false sends notification with no email.  Set forceEmail to null to not force either way
        public async Task SendNotificationToUserAsync(User user, String messageId, Dictionary <string, object> subs, String linkUrl = "", bool?forceEmail = null, bool sendEmailImmediately = false)
        {
            var locale        = user.LocaleOrDefault();
            var fullMessageId = "notifications.notification." + messageId;
            var translated    = await Translator.TranslateAsync(locale, "notifications", fullMessageId, subs);

            translated = HttpUtility.HtmlDecode(translated);
            var sendEmail = !user.EmailNotification.HasValue || user.EmailNotification.Value;

            if (forceEmail.HasValue)
            {
                sendEmail = forceEmail.Value;
            }

            var notification = new Notification
            {
                UserId               = user.Id,
                Message              = translated,
                SendEmail            = sendEmail,
                MessageSubstitutions = subs,
                MessageId            = messageId,
                LinkUrl              = linkUrl
            };
            var updatedNotification = await NotificationRepository.CreateAsync(notification);

            if (sendEmailImmediately)
            {
                BackgroundJobClient.Enqueue <SendNotificationService>(service => service.SendEmailNotificationImmediate(updatedNotification.Id));
            }
        }
示例#2
0
        private static void HandleInput(ConsoleKeyInfo input)
        {
            /*if (input.KeyChar.Equals('s'))
             * {
             *
             *
             *  var newInput = Console.ReadKey();
             *  HandleInput(newInput);
             * }
             * else*/if (input.KeyChar.Equals('q'))
            {
                BackgroundJobClient c = new BackgroundJobClient(_storage);

                //RecurringJob.AddOrUpdate(()=>MyJob.DoSomething(),Cron.
                var b = new BackgroundJobClient(_storage);
                //b.Enqueue(() => Console.WriteLine("my job"));

                c.Enqueue(() => LaunchAppJob.Launch(@"C:\TFSDATA\KissTheFuture\Trunk\shopping.lacage.be\shoppingconsole.lacage.be\bin\Debug\shoppingconsole.lacage.be.exe"));//, new Hangfire.States.EnqueuedState("backgroundsynchro"));
                //c.Enqueue(() => Console.Write('q'));
                Console.WriteLine("Hangfire job enqueued. Press any key to exit...");
                //Thread.Sleep(5000);

                var newInput = Console.ReadKey();
                HandleInput(newInput);
            }
        }
示例#3
0
        public ActionResult UpdateBlogs(FormCollection fc)
        {
            #region 验证用户信息
            string _SessionId       = HttpContext.Request.Cookies["SessionId"].Value;
            string _UserProfileJson = RedisHelper.ItemGet <string>(_SessionId);
            #endregion

            var _Content = fc["editor"];
            var _BlogsId = fc["BlogsId"];

            if (!string.IsNullOrEmpty(_UserProfileJson))
            {
                UserProfile _UserProfile = ToolMethod.GetUerProfile(_UserProfileJson);
                BlogsInfo   _BlogsInfo   = _IBlogsInfoBLL.GetModels(x => x.Id == _BlogsId && x.Delflag == EnumType.DelflagType.正常, true, null, "BlogsInfo").FirstOrDefault();
                _BlogsInfo.BlogContent = _Content;
                _BlogsInfo.UDate       = ToolMethod.GetNow();

                RedisHelper.HashSet <BlogsInfo>("BlogsInfo", _BlogsId, _BlogsInfo);

                BackgroundJobClient _Job = new BackgroundJobClient();
                _Job.Enqueue(() => _IBlogsInfoBLL.Update(_BlogsInfo));

                return(Json(new { Success = true, SuccessModel = "修改博客成功!" }));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
示例#4
0
        public ActionResult ChooseRolePermission(string RolePermissionId)
        {
            try
            {
                if (string.IsNullOrEmpty(RolePermissionId))
                {
                    return(Json(new { Success = false, ErrorMessage = "角色权限关系ID不能为空" }));
                }

                RolePermission _rolePermission = _IRolePermissionBLL.GetModels(x => x.Delflag == EnumType.DelflagType.正常 && x.Id == RolePermissionId, true, x => x.Delflag == EnumType.DelflagType.正常, "RolePermission").FirstOrDefault();

                if (_rolePermission.UsedType == EnumType.UsedType.启用)
                {
                    _rolePermission.UsedType = EnumType.UsedType.未启用;
                }
                else
                {
                    _rolePermission.UsedType = EnumType.UsedType.启用;
                }

                //更新缓存
                _IRolePermissionBLL.UpdateCache("RolePermission", _rolePermission.Id, _rolePermission);

                //异步更新数据库
                BackgroundJobClient _jobs = new BackgroundJobClient();
                _jobs.Enqueue(() => _IRolePermissionBLL.Update(_rolePermission));

                return(Json(new { Success = true, SuccessModel = "选中关系生效!" }));
            }
            catch (Exception ee)
            {
                return(Json(new { Success = false, ErrorMessage = ee.ToString() }));
            }
        }
示例#5
0
        public async Task ProductActivityChangedAsync(ProductActivityChangedArgs args)
        {
            using (var scope = ServiceProvider.CreateScope())
            {
                // Find the Product assoicated with the ProcessId
                var product = await ProductRepository.Get()
                              .Where(p => p.Id == args.ProcessId)
                              .Include(p => p.ProductDefinition)
                              .Include(p => p.Project)
                              .ThenInclude(pr => pr.Owner)
                              .FirstOrDefaultAsync();

                if (product == null)
                {
                    Log.Error($"Could find Product for ProcessId={args.ProcessId}");
                    return;
                }

                var comment = await ReassignUserTasksForProduct(product);

                if (args.TransitionType == TransitionType.Rejection)
                {
                    BackgroundJobClient.Enqueue <SendEmailService>(service => service.SendRejectEmail(product.Id, args, comment));
                }
            }
        }
        private async Task SendScheduledEmailBackgroundAsync(DateTime startDate, string email, int userId)
        {
            var oneDayBeforeEmail   = startDate.AddDays(ONE_DAY_BEFORE_COURSE_START * -1);
            var oneWeekBeforeEmail  = startDate.AddDays(ONE_WEEK_BEFORE_COURSE_START * -1);
            var oneMonthBeforeEmail = startDate.AddDays(ONE_MONTH_BEFORE_COURSE_START * -1);

            var days = startDate - DateTime.UtcNow;

            List <ScheduledJobModel> jobModelList = new List <ScheduledJobModel>();

            if (days.Days >= 30)
            {
                var key = _backgroundJob.Schedule <IMailService>(mailService => mailService
                                                                 .SendScheduledEmail(email, $"test scheduled in {ONE_MONTH_BEFORE_COURSE_START} day(-s)"),
                                                                 new DateTimeOffset(oneMonthBeforeEmail));

                jobModelList.Add(new ScheduledJobModel {
                    Key = key
                });
            }

            if (days.Days >= 14)
            {
                var key = _backgroundJob.Schedule <IMailService>(mailService => mailService
                                                                 .SendScheduledEmail(email, $"test scheduled in {ONE_WEEK_BEFORE_COURSE_START} day(-s)"),
                                                                 new DateTimeOffset(oneWeekBeforeEmail));

                jobModelList.Add(new ScheduledJobModel {
                    Key = key
                });
            }

            if (days.Days >= 1)
            {
                oneDayBeforeEmail = new DateTime(oneDayBeforeEmail.Year, oneDayBeforeEmail.Month, oneDayBeforeEmail.Day,
                                                 HOUR_TO_SEND_EMAIL, 0, 0);

                var key = _backgroundJob.Schedule <IMailService>(mailService => mailService
                                                                 .SendScheduledEmail(email, $"test scheduled in {ONE_DAY_BEFORE_COURSE_START} day(-s)"),
                                                                 new DateTimeOffset(oneDayBeforeEmail));

                _backgroundJob.Enqueue <IMailService>(mailService => mailService
                                                      .SendScheduledEmail(email, $"test scheduled in {days.Days} day(-s)"));
                jobModelList.Add(new ScheduledJobModel {
                    Key = key
                });
            }

            if (jobModelList.Count > 0)
            {
                for (int i = 0; i < jobModelList.Count; i++)
                {
                    _context.ScheduledJobs.Add(new ScheduledJob {
                        Id = jobModelList[i].Key, UserId = userId
                    });
                }
                await _context.SaveChangesAsync();
            }
        }
        public HttpResponseMessage Post()
        {
            var client = new BackgroundJobClient();
            var test   = "test param";

            client.Enqueue(() => CallApi(test));
            return(Request.CreateResponse(HttpStatusCode.Created));
        }
示例#8
0
        private static void Main(string[] args)
        {
            var storage = new SqlServerStorage(
                "Server=(localdb)\\MSSQLLocalDB;Initial Catalog=HostFun;MultipleActiveResultSets=True");
            var client = new BackgroundJobClient(storage);

            client.Enqueue <IGreeter>(greeter => greeter.Greet());
        }
示例#9
0
        public ActionResult QueueServerBJob2(Default1Model model)
        {
            var jobClient = new BackgroundJobClient();
            var jobId     = jobClient.Enqueue(() => BackgroundJobs.QueueServerBJob2());

            model.ServerBJob2Id = jobId;
            return(View("Index", model));
        }
示例#10
0
        public void ApplyWatermark(string picture)
        {
            //IFileSystemStorage storage = new FileSystemStorage();
            var client = new BackgroundJobClient();

            // client.Create()
            client.Enqueue <IFileSystemStorage>(file => file.ApplyWatermark(picture));
        }
示例#11
0
        public void EnqueueTest()
        {
            GlobalConfiguration.Configuration.UseSqlServerStorage("db");
            var client = new BackgroundJobClient();

            for (int i = 0; i < 100; i++)
            {
                var id = client.Enqueue(() => Method(1, DateTime.UtcNow));
            }
        }
示例#12
0
        public void ChangeToDeletedState()
        {
            #region DeletedState
            var client = new BackgroundJobClient();
            var jobId  = client.Enqueue(() => Console.WriteLine("Hello"));

            var state = new DeletedState();
            client.ChangeState(jobId, state, EnqueuedState.StateName);
            #endregion
        }
示例#13
0
文件: Job.cs 项目: clawit/Fan
 public static string Enqueue(Expression <Action> method)
 {
     if (_storage == null || _client == null)
     {
         throw new Exception("Init has not been called yet.");
     }
     else
     {
         return(_client.Enqueue(method));
     }
 }
示例#14
0
        public IHttpActionResult hangefire(string name, string message)
        {
            BackgroundJobClient _jobs = new BackgroundJobClient();
            //新增一個作業
            var parentId = _jobs.Enqueue <BuysomethingCls>(x => x.GobuySomething(name, message));

            //作業完成後執行
            _jobs.ContinueWith <BuysomethingCls>(parentId, x => x.GoHome(parentId, name, message));
            //回傳TaskId
            return(Ok(parentId));
        }
        static void DocExtract(int caseNumber)
        {
            var client = new BackgroundJobClient();
            //var jobId = client.Enqueue(() => SomeMethod(0));
            var jobId1 = client.Enqueue <DocExtractJob1QiSuZhuang>(x => x.ExecuteJob(null, new DocExtractParamsInput()
            {
                CaseNo = 0
            }));
            var jobId2 = client.Enqueue <DocExtractJob2DaBianZhuang>(x => x.ExecuteJob(null, new DocExtractParamsInput()
            {
                CaseNo = 0
            }));
            var jobId3 = client.Enqueue <DocExtractJob3ZhengJuCaiLiao>(x => x.ExecuteJob(null, new DocExtractParamsInput()
            {
                CaseNo = 0
            }));
            var jobId4 = client.Enqueue <DocExtractJob4GongZuoBiLu>(x => x.ExecuteJob(null, new DocExtractParamsInput()
            {
                CaseNo = 0
            }));

            for (int caseNo = 1; caseNo < caseNumber; caseNo++)
            {
                jobId1 = client.ContinueWith <DocExtractJob1QiSuZhuang>(jobId1, x => x.ExecuteJob(null, new DocExtractParamsInput()
                {
                    CaseNo = caseNo
                }));
                jobId2 = client.ContinueWith <DocExtractJob2DaBianZhuang>(jobId1, x => x.ExecuteJob(null, new DocExtractParamsInput()
                {
                    CaseNo = caseNo
                }));
                jobId3 = client.ContinueWith <DocExtractJob3ZhengJuCaiLiao>(jobId1, x => x.ExecuteJob(null, new DocExtractParamsInput()
                {
                    CaseNo = caseNo
                }));
                jobId4 = client.ContinueWith <DocExtractJob4GongZuoBiLu>(jobId1, x => x.ExecuteJob(null, new DocExtractParamsInput()
                {
                    CaseNo = caseNo
                }));
            }
        }
示例#16
0
        protected async Task CreateWorkflowProcessInstance(Product product, WorkflowDefinition workflowDefinition)
        {
            var parms = new CreateInstanceParams(workflowDefinition.WorkflowScheme, product.Id)
            {
                IdentityId = product.Project.Owner.WorkflowUserId.Value.ToString()
            };

            SetProcessProperties(parms, product.ProductDefinition, workflowDefinition);

            await WorkflowInit.Runtime.CreateInstanceAsync(parms);

            BackgroundJobClient.Enqueue <WorkflowProjectService>(service => service.UpdateProjectActive(product.ProjectId));
        }
示例#17
0
        public ActionResult DeleteBlogs(string Id)
        {
            BlogsInfo _BlogsInfo = _IBlogsInfoBLL.GetModels(x => x.Id == Id && x.Delflag == EnumType.DelflagType.正常, true, null, "BlogsInfo").FirstOrDefault();

            _BlogsInfo.Delflag = EnumType.DelflagType.已删除;

            RedisHelper.HashSet("BlogsInfo", Id, _BlogsInfo);

            BackgroundJobClient _Job = new BackgroundJobClient();

            _Job.Enqueue(() => _IBlogsInfoBLL.Update(_BlogsInfo));

            return(Json(new { Success = true, SuccessModel = "删除博客成功!" }));
        }
示例#18
0
        public static void AtomTest()
        {
            var client = new BackgroundJobClient(JobStorage.Current);

            var atomId = client.Enqueue("atom-1", builder =>
            {
                var job1 = builder.Enqueue(() => Wait(5000));
                var job2 = builder.Enqueue(() => Wait(3000));
                var job3 = builder.ContinueJobWith(job2, () => Wait(2000));
                var job4 = builder.Schedule(() => Wait(3000), DateTime.UtcNow.AddSeconds(5));
                var job5 = builder.ContinueJobWith(job4, () => Wait(3000));
            });

            client.ContinueJobWith(atomId, () => Done());
        }
示例#19
0
        public void Add(ParserJob job)
        {
            job.Status = ParserJobStatus.Pending;
            ParserJobsRepository.Add(job);
            ParserJobsRepository.SaveChanges();

            if (job.IsCritical)
            {
                BackgroundJobClient.Enqueue(() => ParseCriticalUrl(job.Id));
            }
            else
            {
                BackgroundJobClient.Enqueue(() => ParseUrl(job.Id));
            }
        }
        public async Task <RegisterOutput> Register(RegisterInput input)
        {
            bool isCaptchaValid = (ReCaptchaClass.Validate(input.CaptchaResponse) == "true" ? true : false);

            if (!isCaptchaValid)
            {
                throw new UserFriendlyException("تیک من ربات نیستم را کلیک نمایید.");
            }
            var userExists = userRepo.GetAll().Any(ff => ff.NormalizedEmailAddress == input.EmailAddress.ToUpper());

            if (userExists)
            {
                throw new UserFriendlyException("آدرس ایمیل وارد شده تکراری است.");
            }

            var user = await _userRegistrationManager.RegisterAsync(
                input.Name,
                input.Surname,
                input.EmailAddress,
                input.EmailAddress,
                input.Password,
                input.KodeMelli,
                input.PhoneNumber,
                false
                );

            user.SetNewEmailConfirmationCode();

            BackgroundJobClient.Enqueue <AccountAppService>(instance => instance.SendConfirmEmailAsync(user));

            var verifyCode = RandomService.GetNDigitsRandomNumber(4).ToString();

            user.MobileVerificationCode     = verifyCode;
            user.MobileVerificationCodeTime = DateTime.Now;
            user.IsPhoneNumberConfirmed     = false;
            await UserManager.UpdateAsync(user);

            var message = $@"مالکینو
کد تایید شما: {verifyCode}
";

            BackgroundJobClient.Enqueue <AccountAppService>(instance => instance.SendSms(message, user.PhoneNumber));

            return(new RegisterOutput
            {
                RegisterResult = true
            });
        }
        public async Task <ResetPassOutput> ResetPass(ResetPassInput model)
        {
            bool IsCaptchaValid = (ReCaptchaClass.Validate(model.CaptchaResponse) == "true" ? true : false);

            if (!IsCaptchaValid)
            {
                return(new ResetPassOutput
                {
                    CaptchaInvalid = true
                });
            }

            try
            {
                var randomService = new RandomService();
                var user          = await UserManager.FindByEmailAsync(model.Email);

                var code = await UserManager.GeneratePasswordResetTokenAsync(user);

                user.IsPasswordReset = true;
                CurrentUnitOfWork.SaveChanges();
                var password = $"{randomService.RandomPassword()}";
                var resetRes = await UserManager.ResetPasswordAsync(user, code, password);

                if (!resetRes.Succeeded)
                {
                    throw new UserFriendlyException("خطایی در تغییر رمز عبور اتفاق افتاده است.");
                }
                BackgroundJobClient.Enqueue <AccountAppService>(instance => instance.SendResetPassEmailAsync(user, password));

                eventBus.Trigger(new PasswordResetEventData {
                    UserId = user.Id, NewPassword = password
                });

                return(new ResetPassOutput
                {
                    Success = true
                });
            }
            catch (Exception ex)
            {
                Logger.Error("Error in reset password", ex);
                return(new ResetPassOutput
                {
                    Success = true
                });
            }
        }
示例#22
0
        public async Task AsyncAtomTest2()
        {
            await Task.Yield();

            var client = new BackgroundJobClient(JobStorage.Current);

            var atomId = client.Enqueue("atom-async", builder =>
            {
                for (var i = 0; i < 150; i++)
                {
                    builder.Enqueue(() => AsyncWaitOrException(1000));
                }
            });

            client.ContinueJobWith(atomId, () => Done());
        }
示例#23
0
        public static void AtomTest2()
        {
            var client = new BackgroundJobClient(JobStorage.Current);

            var atomId = client.Enqueue("atom-2", builder =>
            {
                for (var i = 0; i < 50; i++)
                {
                    builder.Enqueue(() => Done());
                    var job2 = builder.Enqueue(() => Wait(1000));
                    var job3 = builder.ContinueJobWith(job2, () => Wait(500));
                }
            });

            client.ContinueJobWith(atomId, () => Done());
        }
示例#24
0
        public ActionResult AddBlogs(FormCollection fc)
        {
            #region 验证用户信息
            string _SessionId       = HttpContext.Request.Cookies["SessionId"].Value;
            string _UserProfileJson = RedisHelper.ItemGet <string>(_SessionId);
            #endregion

            if (!string.IsNullOrEmpty(_UserProfileJson))
            {
                UserProfile _UserProfile = ToolMethod.GetUerProfile(_UserProfileJson);

                //获取标题
                var _BlogsHeading = fc["BlogsHeading"];
                //获取副标题
                string _BlogsSubHeading = fc["BlogsSubHeading"];
                //获取简介
                var _BlogsAbstract = fc["BlogsAbstract"];
                //获取Ueditor内容
                var _Content = fc["editor"];
                //获取封面图ID
                string _SurfacePlot = fc["SurfacePlot"];

                BlogsInfo _BlogsInfo = new BlogsInfo()
                {
                    Id               = ToolMethod.GetGuid(),
                    BlogAuthorId     = _UserProfile.Id,
                    BlogAuthorName   = _UserProfile.NickName,
                    BlogContent      = _Content,
                    BlogHeading      = _BlogsHeading,
                    BlogsSurfacePlot = _SurfacePlot,
                    BlogSubHeading   = _BlogsSubHeading,
                    CDate            = ToolMethod.GetNow(),
                    CommentNum       = 0,
                    Delflag          = EnumType.DelflagType.正常,
                    UDate            = ToolMethod.GetNow(),
                    LikeNum          = 0,
                    BlogAbstarct     = _BlogsAbstract,
                };

                RedisHelper.HashSet <BlogsInfo>("BlogsInfo", _BlogsInfo.Id, _BlogsInfo);

                BackgroundJobClient _Job = new BackgroundJobClient();
                _Job.Enqueue(() => _IBlogsInfoBLL.Add(_BlogsInfo));
            }

            return(Json(new { Success = true, SuccessModel = "添加博客成功!" }));
        }
示例#25
0
        public async Task AsyncAtomTest()
        {
            await Task.Yield();

            var client = new BackgroundJobClient(JobStorage.Current);

            var atomId = client.Enqueue("atom-async", builder =>
            {
                var job1 = builder.Enqueue(() => AsyncWait(5000));
                var job2 = builder.Enqueue(() => AsyncWait(3000));
                var job3 = builder.ContinueJobWith(job2, () => AsyncWait(2000));
                var job4 = builder.Schedule(() => AsyncWait(3000), DateTime.UtcNow.AddSeconds(5));
                var job5 = builder.ContinueJobWith(job4, () => AsyncWait(3000));
            });

            client.ContinueJobWith(atomId, () => Done());
        }
示例#26
0
        public static object TaskBurst()
        {
            var bjc = new BackgroundJobClient(JobStorage.Current);

            const int tasks = 5000;

            Parallel.For(0, tasks, new ParallelOptions {
                MaxDegreeOfParallelism = 10
            }, i =>
            {
                bjc.Enqueue(() => ContinuationPartC());
            });

            return(new
            {
                created = tasks
            });
        }
示例#27
0
        static void test()
        {
            //Hangfire.GlobalConfiguration.Configuration.UseStorage();

            IBackgroundJobClient client = new BackgroundJobClient();

            var jobid = client.Enqueue(() => Console.WriteLine(string.Empty));

            jobid = client.Schedule(() => Console.WriteLine(string.Empty), TimeSpan.FromHours(10));

            //client.Create()

            var server = new BackgroundJobServer(new BackgroundJobServerOptions()
            {
            });

            //server.Start();
            //server.Stop();
            server.Dispose();
        }
示例#28
0
        public override void OnException(ExceptionContext filterContext)
        {
            string _ControllerName = filterContext.Controller.ToString();

            #region 记录异常日志
            if (_ControllerName != "Account")
            {
                if (filterContext.HttpContext.Request.Cookies["SessionId"] != null)
                {
                    string _SessionId       = filterContext.HttpContext.Request.Cookies["SessionId"].Value;
                    string _UserProfileJson = RedisHelper.ItemGet <string>(_SessionId);
                    if (_UserProfileJson != null)
                    {
                        //获取用户账号实体
                        _UserProfile = JsonConvert.DeserializeObject <UserProfile>(_UserProfileJson);

                        LogInfo _logInfo = new LogInfo()
                        {
                            Id      = ToolMethod.GetGuid(),
                            Content = "【请求异常】:"
                                      + "【请求路径:" + filterContext.HttpContext.Request.Path + "】"
                                      + "【请求方式:" + filterContext.HttpContext.Request.HttpMethod + "】"
                                      + "【异常内容:" + filterContext.Exception.Message.ToString() + "】",
                            AccountId   = _UserProfile.Id,
                            AccountName = _UserProfile.NickName,
                            Level       = EnumType.LogLevel.ERROR,
                            CDate       = ToolMethod.GetNow()
                        };

                        BackgroundJobClient _jobs             = new BackgroundJobClient();
                        Expression <Action> _actionExpression = () => _ILogInfoBLL.Add(_logInfo);
                        _jobs.Enqueue(_actionExpression);
                    }
                }
                else
                {
                    filterContext.HttpContext.Response.Redirect("/Account/Login?session=false");
                }
            }
            #endregion
        }
示例#29
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            #region 获取Action & Controller信息
            string _ActionName     = filterContext.ActionDescriptor.ActionName;
            string _ControllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            #endregion

            #region 记录操作日志
            if (_ControllerName != "Account")
            {
                if (filterContext.HttpContext.Request.Cookies["SessionId"] != null)
                {
                    string _SessionId       = filterContext.HttpContext.Request.Cookies["SessionId"].Value;
                    string _UserProfileJson = RedisHelper.ItemGet <string>(_SessionId);
                    if (_UserProfileJson != null)
                    {
                        //获取用户账号实体
                        _UserProfile = JsonConvert.DeserializeObject <UserProfile>(_UserProfileJson);

                        LogInfo _logInfo = new LogInfo()
                        {
                            Id          = ToolMethod.GetGuid(),
                            Content     = _UserProfile.NickName + "调用了 " + _ControllerName + "Controller下的" + _ActionName + "操作",
                            AccountId   = _UserProfile.Id,
                            AccountName = _UserProfile.NickName,
                            Level       = EnumType.LogLevel.INFO,
                            CDate       = ToolMethod.GetNow()
                        };

                        BackgroundJobClient _jobs             = new BackgroundJobClient();
                        Expression <Action> _actionExpression = () => _ILogInfoBLL.Add(_logInfo);
                        _jobs.Enqueue(_actionExpression);
                    }
                }
                else
                {
                    filterContext.HttpContext.Response.Redirect("/Account/Login?session=false");
                }
            }
            #endregion
        }
示例#30
0
        public void Execute(BackgroundProcessContext context)
        {
            var monitoringApi = context.Storage.GetMonitoringApi();

            if (monitoringApi.EnqueuedCount("default") > _count)
            {
                context.Wait(_delay);
                return;
            }

            var client = new BackgroundJobClient(context.Storage)
            {
                RetryAttempts = 15
            };

            for (var i = 0; i < _count; i++)
            {
                context.StoppingToken.ThrowIfCancellationRequested();
                client.Enqueue <IHarnessV1>(x => x.Perform(0));
            }
        }