private void LoadPart(DatabaseChunkPart part, string p)
        {
            var loadAttempt = 0;
            var loaded      = false;

            while (!loaded)
            {
                try
                {
                    loadAttempt++;
                    part.Load();
                    loaded = true;
                }
                catch (Exception ex)
                {
                    if (loadAttempt <= 11)
                    {
                        Logger.Write(_chunkId, LogMessageTypes.Warning,
                                     p + ") load attempt=" + loadAttempt + ") " + Logger.CreateExceptionString(ex));
                        part.Reset();
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
示例#2
0
        public void Process()
        {
            try
            {
                Console.WriteLine("DatabaseChunkBuilder");
                var dbChunk = new DbChunk(Settings.Settings.Current.Building.BuilderConnectionString);
                var part    = new DatabaseChunkPart(_chunkId, _createPersonBuilder, "0", 0);

                var timer = new Stopwatch();
                timer.Start();

                part.Load();
                Logger.Write(_chunkId, LogMessageTypes.Info,
                             $"Loaded - {timer.ElapsedMilliseconds} ms | {(GC.GetTotalMemory(false) / 1024f) / 1024f} Mb");

                part.Build();
                part.Save();

                dbChunk.ChunkComplete(_chunkId, Settings.Settings.Current.Building.Id.Value);
                Console.WriteLine($"ChunkId={_chunkId} was complete");
            }
            catch (Exception e)
            {
                Logger.WriteError(_chunkId, e);

                throw;
            }
        }