Exemplo n.º 1
0
        public async Task <int> SaveAsync(T entity, bool IsCache, string Cahekey)
        {
            if (IsCache)
            {
                if (!string.IsNullOrEmpty(Cahekey))
                {
                    Parallel.Invoke(() => _backgroundJob.AddEnque <ICacheService>(x => x.RemoveCache(Cahekey)));
                }
            }

            return(await SaveAsync(entity));
        }
            public async Task <Response> Handle(User_Lst_cmd request, CancellationToken cancellationToken)
            {
                Response response = new Response();

                try
                {
                    bool cachexists = false;
                    Task <List <TblUsermaster> > data = _cache.GetCachedObject <TblUsermaster>("users");

                    cachexists = data == null ? true : data.Result != null ? true : false;
                    if (cachexists)
                    {
                        response.ResponseObject = data.Result;
                    }
                    else
                    {
                        List <TblUsermaster> dbdata = (List <TblUsermaster>) await _dapper.GetDataAsync <TblUsermaster>("users", "1", null, CommandType.Text);

                        if (dbdata != null)
                        {
                            Parallel.Invoke(() => _backgroundJob.AddEnque <ICacheService>(x => x.SetCachedObject("users", dbdata)));

                            response.ResponseObject = dbdata;
                        }
                    }
                }
                catch (Exception ex)
                {
                    response.ResponseStatus = false;
                    response.ResponseObject = ex.Message + " ~ " + ex.InnerException;
                    response.StatusCode     = HttpStatusCode.BadRequest;
                }
                return(response);
            }
        public void SaveMailNotification(string From, string To, string Subject, string Body)
        {
            NotficationCls notfication = new()
            {
                MsgFrom     = From,
                MsgTo       = To,
                MsgSubject  = Subject,
                MsgBody     = Body,
                MsgSatus    = NotificationStatus.Pending.ToString(),
                MsgType     = NotificationType.Mail.ToString(),
                CreatedDate = System.DateTime.Now,
            };

            _backgroundJob.AddEnque <IDapper <NotficationCls> >(x => x.SaveNotificationAsync(notfication));
        }
Exemplo n.º 4
0
            public async Task <Response> Handle(List_SendEmail request, CancellationToken cancellationToken)
            {
                Response response = new Response();

                List <NotficationCls> dbdata = (List <NotficationCls>) await _query.GetDataAsync <NotficationCls>("JobScheduler", "1", null, CommandType.Text);

                Parallel.ForEach(dbdata, data =>
                {
                    string jobid = _backgroundJob.AddEnque <INotificationMsg>(x => x.SendAsync(data));
                });

                //foreach (NotficationCls data in dbdata)
                //{
                //    string jobid = this._backgroundJob.AddEnque<INotificationMsg>(x => x.Send(data));
                //}

                //response.ResponseObject = dbdata;

                return(response);
            }