public static void PerformAction(string module, string method)
        {
            _globalEnv.LoadMemory(MachineInstance.Current);

            ApplicationDbContext dbContext = null;

            try
            {
                dbContext = _dbBridge?.CreateContext();

                // TODO Сделать нормальный наконец способ доступа к ИБ
                if (DatabaseExtensions.Infobase != null)
                {
                    DatabaseExtensions.Infobase.DbContext = dbContext;
                }

                var scriptObject = (IRuntimeContextInstance)_globalEnv.GetGlobalProperty(module);
                var methodId     = scriptObject.FindMethod(method);
                scriptObject.CallAsProcedure(methodId, new IValue[0]);
            }
            finally
            {
                dbContext?.Dispose();
                if (DatabaseExtensions.Infobase != null)
                {
                    DatabaseExtensions.Infobase.DbContext = null;
                }
            }
        }
 public static void PrepareThread(this MachineInstance machine, RuntimeEnvironment env)
 {
     if (!machine.IsRunning)
     {
         env.LoadMemory(machine);
     }
 }
Esempio n. 3
0
        public static void PerformAction(string module, string method)
        {
            _globalEnv.LoadMemory(MachineInstance.Current);

            var scriptObject = (IRuntimeContextInstance)_globalEnv.GetGlobalProperty(module);
            var methodId     = scriptObject.FindMethod(method);

            scriptObject.CallAsProcedure(methodId, new IValue[0]);
        }