Ejemplo n.º 1
0
        private static void Build(BuilderController builderController)
        {
            var dbChunk = new DbChunk(Settings.Current.Building.BuilderConnectionString);
             int? chunkId = null;
             while (true)
             {
            try
            {
               builderController.RefreshState();
               if (builderController.Builder.State == BuilderState.Stopping)
                  break;

               if (builderController.Builder.State == BuilderState.Stopped)
                  break;

               if (builderController.Builder.State == BuilderState.Error)
                  break;

               if (builderController.Builder.State == BuilderState.Unknown || builderController.Builder.State == BuilderState.Idle)
                  continue;

               chunkId = dbChunk.TakeChunk(Settings.Current.Building.Id.Value);
               if (!chunkId.HasValue) break;

               var builder = new ChunkBuilder(new ChunkData { Id = chunkId.Value }, GetBuilderType(Settings.Current.Building.Vendor));
               var loaded_chunk = builder.Load();
               var built_chunk = loaded_chunk.Build();
               var task = built_chunk.Save();
               tasks.Add(task);
            }
            catch (Exception e)
            {
               if (chunkId.HasValue)
                  Logger.WriteError(chunkId, e);
               else
                  Logger.Write(null, Settings.Current.Building.Id.Value, null, LogMessageTypes.Error, Logger.CreateExceptionString(e));

               builderController.UpdateState(BuilderState.Error);
            }
             }
        }
Ejemplo n.º 2
0
        private static void Build(BuilderController builderController)
        {
            var dbChunk = new DbChunk(Settings.Current.Building.BuilderConnectionString);
            int?chunkId = null;

            while (true)
            {
                try
                {
                    builderController.RefreshState();
                    if (builderController.Builder.State == BuilderState.Stopping)
                    {
                        break;
                    }

                    if (builderController.Builder.State == BuilderState.Stopped)
                    {
                        break;
                    }

                    if (builderController.Builder.State == BuilderState.Error)
                    {
                        break;
                    }

                    if (builderController.Builder.State == BuilderState.Unknown || builderController.Builder.State == BuilderState.Idle)
                    {
                        continue;
                    }


                    chunkId = dbChunk.TakeChunk(Settings.Current.Building.Id.Value);
                    if (!chunkId.HasValue)
                    {
                        break;
                    }

                    var builder = new ChunkBuilder(new ChunkData {
                        Id = chunkId.Value
                    }, GetBuilderType(Settings.Current.Building.Vendor));
                    var loaded_chunk = builder.Load();
                    var built_chunk  = loaded_chunk.Build();
                    var task         = built_chunk.Save();
                    tasks.Add(task);
                }
                catch (Exception e)
                {
                    if (chunkId.HasValue)
                    {
                        Logger.WriteError(chunkId, e);
                    }
                    else
                    {
                        Logger.Write(null, Settings.Current.Building.Id.Value, null, LogMessageTypes.Error, Logger.CreateExceptionString(e));
                    }


                    builderController.UpdateState(BuilderState.Error);
                }
            }
        }