Пример #1
0
 private CacheProgramResults(ExecutionContent executionResults, bool processExecutionFailed, int processExitCode, string stdOut, string stdErr)
 {
     ExecutionResults       = executionResults;
     ProcessExecutionFailed = processExecutionFailed;
     ProcessExitCode        = processExitCode;
     StdOut = stdOut;
     StdErr = stdErr;
 }
        public static CacheProgramResults CreateFromResultsFile(string resultsFilePath, ProcessRunResults processRunResults)
        {
            ExecutionContent executionResults;

            if (File.Exists(resultsFilePath))
            {
                executionResults = JsonConvert.DeserializeObject <ExecutionContent>(File.ReadAllText(resultsFilePath));
            }
            else
            {
                executionResults = new ExecutionContent
                {
                    IsError      = true,
                    ErrorMessage = $"ResultsFilePath does not exist: {resultsFilePath}"
                };
            }

            return(new CacheProgramResults(executionResults, false, 0, processRunResults.StandardOut, processRunResults.StandardError));
        }
Пример #3
0
        static void Main(string[] args)
        {
            __InitExceptionEventer();

            #region 主要环境初始化和硬件检查
            StartTime               = DateTime.Now;
            Console.Title           = "XCWorld Server - Forgetive";
            ItemStorage.OpenedFiles = new List <FileStream>();
            if (args.Length != 0)
            {
                Data.InitData(args[0]);
            }
            else
            {
                return;
            }
            Logger.Init();

#if !__LINUX_ARM
            CheckHardware();
#endif

            #endregion

            #region 参数处理
            if (args.Length == 1)
            {
            }
            else if (args.Length == 2)
            {
#if DEBUG
                sudoExecutionContent = args[1];
                isDebugMode          = true;
                Logger.WriteLine(LogLevel.Info, "已启用Debug模式");
#else
                Logger.WriteLine(LogLevel.Error, "正式版不允许手动设置权限");
                return;
#endif
            }
            else
            {
                Logger.WriteLine(LogLevel.Error, "仅允许添加一个具有完全权限执行体的名称");
                return;
            }

#if DEBUG
            Logger.WriteLine(LogLevel.Warning, "Forgetive Server SDK版");
            Logger.WriteLine(LogLevel.Warning, "测试版支持对应版本的 Forgetive Developer For Win10 客户端");
#endif
            if (!Environment.Is64BitProcess)
            {
                Logger.WriteLine(LogLevel.Error, "Forgetive Server 运行在32位进程下,进程仅允许最高1.5GB内存,这将导致不可恢复的错误。");
            }
            #endregion

            Logger.WriteLine("Forgetive Server 初始化网络...");

            key_device         = Data.GetTable("key", "device");
            key_banned         = Data.GetTable("key", "banned");
            key_nick           = Data.GetTable("key", "nick");
            nick_xcoin         = Data.GetTable("nick", "xcoin");
            nick_bp            = Data.GetTable("nick", "bp");
            nick_isop          = Data.GetTable("nick", "isop");
            nick_newplayerstep = Data.GetTable("nick", "newplayerstep");

            ForgetiveServer.Init();
            ItemUsage.Init();
            ItemStorage.Init();
            ServerVersion.Init();
            engine = new CommandEngine();

            assemblies = new List <Assembly>();
            assemblies.Add(Assembly.GetAssembly(typeof(Program)));
            assembliesMd5 = new List <string>();
            assembliesMd5.Add("INNEREXT");
            Logger.WriteLine(LogLevel.Info, "加载 Forgetive EXT {0}", "ForgetiveServer [Inner]");

            DirectoryInfo info = new DirectoryInfo(Data.RootPath + "/Extension");
            if (!info.Exists)
            {
                info.Create();
            }
            FileInfo[] files = info.GetFiles();
            for (int i = 0; i < files.Length; i++)
            {
                if (files[i].Extension == ".dll")
                {
                    try
                    {
                        assembliesMd5.Add(Hash(files[i].FullName));
                        Assembly assembly = Assembly.LoadFile(files[i].FullName);
                        assemblies.Add(assembly);
                    }
                    catch
                    {
                        Logger.WriteLine(LogLevel.Warning, "无法加载 {0} : 无效的 Forgetive EXT 文件", files[i].Name);
                        assembliesMd5.RemoveAt(assembliesMd5.Count - 1);
                    }
                    Logger.WriteLine(LogLevel.Info, "加载 Forgetive EXT {0}", files[i].Name);
                }
            }
            ExecutionContent.Load(assemblies.ToArray());

            List <Assembly> ass = new List <Assembly>(assemblies);
            ass.Add(Assembly.GetEntryAssembly());
            GlobalServer.Init(ass.ToArray());
            NPCManager.Init();

            TimeSpan total = DateTime.Now - StartTime;
            Logger.WriteLine(LogLevel.Default, "初始化完成({0}s),使用help查看指令列表", total.TotalSeconds);

            while (true)
            {
                string cmd = Console.ReadLine();
                engine.Execute(cmd);
            }
        }