コード例 #1
0
        public async Task <IActionResult> MapViewSaveAs([FromBody] MapView value)
        {
            MapView mapView = new MapView();

            try
            {
                mapView.UserName     = this.User.Identity.Name;
                mapView.BookmarkName = value.BookmarkName;
                mapView.Application  = value.Application;
                mapView.Data         = value.Data;
                mapView.Timestamp    = DateTime.Now;
                mapView.ShareId      = Guid.NewGuid().ToString();
                await _camnContext.MapViews.AddAsync(mapView);

                await _camnContext.SaveChangesAsync();
            }
            catch (Exception e)
            {
                return(StatusCode(Microsoft.AspNetCore.Http.StatusCodes.Status500InternalServerError, e));
            }

            return(Ok(mapView));
        }
コード例 #2
0
ファイル: BackgroundLogger.cs プロジェクト: dnvgithub/camn
        private void DoWork(object state)
        {
            if (!_inMemoryLog.IsEmpty())
            {
                Task.Run(async() =>
                {
                    DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder <CamnContext>();
                    optionsBuilder.UseSqlServer(_config.GetConnectionString("CamnContextWriter"));

                    CamnContext camnContext = new CamnContext(optionsBuilder.Options);
                    while (!_inMemoryLog.IsEmpty())
                    {
                        UserAction action = _inMemoryLog.Get();
                        if (null != action)
                        {
                            await camnContext.UserActions.AddAsync(action);
                        }
                    }
                    await camnContext.SaveChangesAsync();
                }).Wait();
            }
        }