Пример #1
0
        public void Build_Plugin_Finish(EngineState s, Dictionary <string, string> localVars)
        {
            if (s.DisableLogger)
            {
                return;
            }

            if (s.DelayedLogging)
            {
                DB.InsertAll(BuildLogPool);
                BuildLogPool.Clear();
            }

            if (s.DisableLogger == false)
            {
                long buildId  = s.BuildId;
                long pluginId = s.PluginId;

                // Plugins
                pluginDict.TryRemove(pluginId, out Tuple <DB_Plugin, Stopwatch> tuple);
                if (tuple == null)
                {
                    throw new KeyNotFoundException($"Unable to find DB_Plugin Instance, id = {pluginId}");
                }

                DB_Plugin dbPlugin = tuple.Item1;
                Stopwatch watch    = tuple.Item2;
                watch.Stop();

                dbPlugin.ElapsedMilliSec = watch.ElapsedMilliseconds;
                if (localVars != null)
                {
                    List <DB_Variable> varLogs = new List <DB_Variable>(localVars.Count);
                    foreach (var kv in localVars)
                    {
                        DB_Variable dbVar = new DB_Variable()
                        {
                            BuildId  = buildId,
                            PluginId = pluginId,
                            Type     = VarsType.Local,
                            Key      = kv.Key,
                            Value    = kv.Value,
                        };
                        varLogs.Add(dbVar);

                        // Fire Event
                        VariableUpdated?.Invoke(this, new VariableUpdateEventArgs(dbVar));
                    }
                    DB.InsertAll(varLogs);
                }

                DB.Update(dbPlugin);

                // Fire Event
                if (s.DelayedLogging)
                {
                    PluginUpdated?.Invoke(this, new PluginUpdateEventArgs(dbPlugin));
                }
            }
        }
Пример #2
0
        public long Build_Init(EngineState s, string name)
        {
            if (s.DisableLogger)
            {
                return(0);
            }

            // Build Id
            DB_BuildInfo dbBuild = new DB_BuildInfo()
            {
                StartTime = DateTime.UtcNow,
                Name      = name,
            };

            DB.Insert(dbBuild);
            buildDict[dbBuild.Id] = dbBuild;
            s.BuildId             = dbBuild.Id;

            // Fire Event
            BuildInfoUpdated?.Invoke(this, new BuildInfoUpdateEventArgs(dbBuild));

            // Variables - Fixed, Global, Local
            List <DB_Variable> varLogs = new List <DB_Variable>();

            foreach (VarsType type in Enum.GetValues(typeof(VarsType)))
            {
                Dictionary <string, string> dict = s.Variables.GetVarDict(type);
                foreach (var kv in dict)
                {
                    DB_Variable dbVar = new DB_Variable()
                    {
                        BuildId = dbBuild.Id,
                        Type    = type,
                        Key     = kv.Key,
                        Value   = kv.Value,
                    };
                    varLogs.Add(dbVar);

                    // Fire Event
                    VariableUpdated?.Invoke(this, new VariableUpdateEventArgs(dbVar));
                }
            }
            DB.InsertAll(varLogs);

            System_Write(new LogInfo(LogState.Info, $"Build [{name}] started"));

            return(dbBuild.Id);
        }
Пример #3
0
 public VariableUpdateEventArgs(DB_Variable log) : base()
 {
     Log = log;
 }