Example #1
0
        private async Task CheckGameNew()
        {
            ResultGameVerification result = CheckSkyrim();

            ModVersion.Load();
            FileWatcher.Init();

            if (!Mods.ExistMod("SKSE") && !result.IsSKSEFound && MessageBox.Show(Res.SKSENotFound, Res.Warning, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                blockMainBtn = true;
                await GetSKSE();

                Mods.EnableMod("SKSE");
                blockMainBtn = false;
            }
            else if (Mods.ExistMod("SKSE"))
            {
                Mods.EnableMod("SKSE");
            }

            try
            {
                if (!result.IsRuFixConsoleFound && ModVersion.HasRuFixConsole == null &&
                    MessageBox.Show(Res.SSERFix, Res.Warning, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    blockMainBtn = true;
                    if (!Mods.ExistMod("RuFixConsole"))
                    {
                        await GetRuFixConsole();
                    }
                    Mods.EnableMod("RuFixConsole");

                    ModVersion.HasRuFixConsole = true;
                    ModVersion.Save();

                    blockMainBtn = false;
                }
                else
                {
                    ModVersion.HasRuFixConsole = result.IsRuFixConsoleFound;
                    ModVersion.Save();
                }
            }
            catch (Exception er)
            {
                blockMainBtn = false;
                Logger.FatalError("CheckGameNew_SSERFix", er);
            }
        }
Example #2
0
        private async Task CheckGameOld()
        {
            ResultGameVerification result = CheckSkyrim();

            ModVersion.Load();
            FileWatcher.Init();

            if (!result.IsSKSEFound && MessageBox.Show(Res.SKSENotFound, Res.Warning, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                blockMainBtn = true;
                await InstallSKSE();

                blockMainBtn = false;
            }

            try
            {
                if (!result.IsRuFixConsoleFound && ModVersion.HasRuFixConsole == null &&
                    MessageBox.Show(Res.SSERFix, Res.Warning, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    blockMainBtn = true;
                    await InstallRuFixConsole();

                    ModVersion.Save();
                    blockMainBtn = false;
                }
                else
                {
                    ModVersion.HasRuFixConsole = result.IsRuFixConsoleFound;
                    ModVersion.Save();
                }
            }
            catch (Exception er)
            {
                blockMainBtn = false;
                Logger.FatalError("CheckGame_SSERFix", er);
            }
        }
Example #3
0
        private async Task CheckGame()
        {
            string pathToSkyrim           = Settings.PathToSkyrim;
            ResultGameVerification result = default;

            try
            {
                do
                {
                    while (string.IsNullOrEmpty(pathToSkyrim) || !Directory.Exists(pathToSkyrim))
                    {
                        string path = GameVerification.GetGameFolder();
                        if (string.IsNullOrEmpty(path))
                        {
                            App.AppCurrent.Shutdown();
                            Close();
                            return;
                        }
                        pathToSkyrim = path;
                    }

                    result = GameVerification.VerifyGame(pathToSkyrim, null);
                    if (result.IsGameFound)
                    {
                        if (Settings.PathToSkyrim != pathToSkyrim)
                        {
                            Settings.PathToSkyrim = pathToSkyrim;
                            Settings.Save();
                        }
                        break;
                    }

                    pathToSkyrim = null;
                    MessageBox.Show(Res.SkyrimNotFound, Res.Error);
                } while (true);
            }
            catch (Exception er)
            {
                Logger.FatalError("Wind_Loaded_1", er);
                MessageBox.Show(Res.InitError, Res.Error);
                Close();
            }

            ModVersion.Load();
            FileWatcher.Init();

            try
            {
                if (!result.IsSKSEFound && MessageBox.Show(Res.SKSENotFound, Res.Warning, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    await InstallSKSE();
                }
                if (!result.IsRuFixConsoleFound &&
                    ModVersion.HasRuFixConsole == null &&
                    MessageBox.Show(Res.SSERFix, Res.Warning, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    await InstallRuFixConsole();

                    ModVersion.Save();
                }
                else
                {
                    ModVersion.HasRuFixConsole = result.IsRuFixConsoleFound;
                    ModVersion.Save();
                }
            }
            catch (Exception er)
            {
                Logger.FatalError("Wind_Loaded_2", er);
            }
        }
Example #4
0
        public static void Main(string[] args)
        {
            List <string> error = new List <string>();

            //IDataService xmlService = new XmlDataService();
            //XMLOptions xml = new XMLOptions();
            //FileWatcher watcher = new FileWatcher();

            try
            {
                log.Info("**********Application Start**********");
                //建立xml資料夾監聽
                watcher = new FileWatcher();
                watcher.Init();

                //初始化伺服端設定檔
                cfg = new Config();
                cfg.Init();

                //var client = new WinSCPClient(cfg);
                //建立winscp client
                client = new WinSCPClient(cfg);

                //監聽新增事件
                watcher.EvtGetFileName += new FileWatcher.DelGetFileName(GetFileName);

                //初始化,xml資料夾內檔案執行傳輸
                foreach (var oneXml in watcher.FileList)
                {
                    Task task = new Task(() =>
                    {
                        MainOperate(oneXml);
                    });
                    tasks.Add(task);
                }

                while (0 < tasks.Count)
                {
                    tasks[0].Start();
                    Task.WaitAny(tasks[0]);

                    var temp = tasks.ToList();
                    temp.RemoveAt(0);
                    tasks = temp;
                }



                //var cfg = new Config();
                //cfg.Init();

                ////var client = new WinSCPClient(cfg);
                //client = new WinSCPClient(cfg);
                //// 取得檔案
                //var filepath = xmlService.GetFilePath();
                //var files = xmlService.GetRecords(filepath);

                //client.Operate(files);

                //foreach (var f in files)
                //{
                //    if (f.Done)
                //    {
                //        error.Add($"[完成]檔案名稱:{f.FileName}\n傳輸速率:{f.TransferSpeed.ToString("#,#")}(kB/s)");
                //    }
                //    else
                //    {
                //        error.Add($"[失敗]檔案名稱:{f.FileName}\n{f.ErrorMessage}");
                //    }
                //}

                ////傳輸完成後產生紀錄檔
                //xml.CreateXmlFile(files, $"{cfg.FinishXMLFilePath}{DateTime.Now.ToString("yyyyMMddHHmm")}.xml");
            }
            catch (ArgumentException ex)
            {
                error.Add($"伺服器連線資訊設定檔錯誤: {ex.Message}");
                Console.WriteLine($"伺服器連線資訊設定檔錯誤: {ex.Message}");
            }
            catch (Exception ex)
            {
                error.Add($"Error: {ex.Message}");
            }
            finally
            {
                if (error.Count > 0)
                {
                    foreach (var er in error)
                    {
                        log.Error(er);
                        Console.WriteLine(er);
                    }
                }
                log.Info("**********Application End**********");
                Console.WriteLine("The End.");

                Console.ReadKey();
            }
        }