Example #1
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);
        }