示例#1
0
        public virtual void Update(List <T> entities)
        {
            using (new TimeMonitor(GetPrefix(entities.Select(o => o.Id).ToList())))
            {
                try
                {
                    foreach (var entity in entities)
                    {
                        entity.LastUpdate = DateTime.Now;
                        if (this.GetContext() != null)
                        {
                            entity.LastUpdatedBy = this.GetContext().UserId;
                        }
                    }

                    var task = Task.Run(async() => { await collection.UpdateEntitiesAsync(entities); });
                    task.Wait();

                    if (IsCacheReady())
                    {
                        cache.Set(entities);
                    }

                    LogInformation("Update", string.Join(",", entities.Select(o => o.Id).ToList()));
                }
                catch (Exception ex)
                {
                    LogException(ex);
                    return;
                }
            }
        }
示例#2
0
文件: BaseService.cs 项目: wiiee/core
        public virtual void Update(List <T> entities)
        {
            using (new TimeMonitor(GetPrefix(entities.Select(o => o.Id).ToList())))
            {
                try
                {
                    foreach (var entity in entities)
                    {
                        if (typeof(T) != typeof(HistoryService))
                        {
                            ProcessHistory(HistoryType.Update, entity.Id, JsonConvert.SerializeObject(entity), this.GetContext().UserId);
                        }
                    }

                    var task = Task.Run(async() => { await collection.UpdateEntitiesAsync(entities); });
                    task.Wait();

                    if (this.GetContext().IsUseCache&& IsCacheReady())
                    {
                        cache.Set(entities);
                    }

                    LogInformation("Update", string.Join(",", entities.Select(o => o.Id).ToList()));
                }
                catch (Exception ex)
                {
                    LogException(ex);
                    return;
                }
            }
        }