Пример #1
0
 private void LibrarySection_Loaded(object sender, RoutedEventArgs e)
 {
     #region UIEngine
     OnlineVersionLabel.Content += WolfClient.GetOnlineFileInfo("Library", "Wolf Project", "UIEngine", "UIEngine.info")?["Version"];
     LocalVersionLabel.Content  += WolfClient.GetLocalFileInfo("Library", "Wolf Project", "UIEngine", "UIEngine.info")?["Version"];
     #endregion
 }
Пример #2
0
        /// <summary>
        /// Tries to fetch server status information and return a new server based on it
        /// </summary>
        /// <param name="address"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        private static async Task <Server> GetNewServer(string address, int port, TimeSpan timeout)
        {
            var cancellationTokenSource = new CancellationTokenSource();
            var client = new WolfClient(new WolfClientOptions {
                Address = address, Port = port
            });
            var task      = client.GetStatus();
            var completed = await Task.WhenAny(task, Task.Delay(timeout, cancellationTokenSource.Token));

            if (completed == task)
            {
                cancellationTokenSource.Cancel();
            }
            else
            {
                return(null);
            }

            if (task.Result == null)
            {
                return(null);
            }

            return(new Server
            {
                Address = address,
                Port = port,
                LastQueryTime = DateTime.UtcNow,
                LatestServerStatus = task.Result,
                GetStatusFailCount = 0
            });
        }
Пример #3
0
        private void AuthorizationClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if ((LoginBox.Text.Length > 3 && LoginBox.Text.Length <= 25) && (PasswordBox.Password.Length > 5))
                {
                    if ((string)AuthorizationButton.Content == "Авторизироваться")
                    {
                        if (WolfClient.ClientAuthorize("http://wolf.wolfproject.ru/UIUser/LogIn/", LoginBox.Text.ToLower(), PasswordBox.Password))
                        {
                            Properties.Settings.Default.Login        = LoginBox.Text;
                            Properties.Settings.Default.Password     = PasswordBox.Password;
                            Properties.Settings.Default.IsAuthorized = true;
                            Properties.Settings.Default.Save();

                            Hide();
                            new MainMenu().Show();
                        }
                        else
                        {
                            MessageBox.Show("Вы ввели неправильный логин или пароль! \nВозможно ваш HWID больше не действителен!", "Ошибка авторизации", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                    }
                    else
                    {
                        if (WolfClient.ClientAuthorize("http://wolf.wolfproject.ru/UIUser/SignUp/", LoginBox.Text.ToLower(), PasswordBox.Password))
                        {
                            Properties.Settings.Default.Login        = LoginBox.Text;
                            Properties.Settings.Default.Password     = PasswordBox.Password;
                            Properties.Settings.Default.IsAuthorized = true;
                            Properties.Settings.Default.Save();

                            Hide();
                            new MainMenu().Show();
                        }
                        else
                        {
                            MessageBox.Show("Такой пользователь уже создан!", "Ошибка регистрации!", MessageBoxButton.OK, MessageBoxImage.Stop);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Логин должен быть больше 3 символов! \nПароль должен быть больше 7 символов!", "Ошибка авторизации", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception EX)
            {
                MessageBox.Show(EX.Message, "Ошибка авторизации", MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
Пример #4
0
        public static async Task Main(string[] args)
        {
            var client = new WolfClient()
                         .SetupCommands()
                         .WithConfig("appsettings.json")
                         .GetConfig(out SettingsRoot settings)
                         .WithSerilog()
                         .WithServices(c =>
            {
                c.AddTransient <INsfwService, NsfwService>()

                /*.AddTransient<INsfwDataService, NsfwDataService>()
                 * .AddRedis(r =>
                 * {
                 *      r.EndPoints.Add(settings.Redis.Host);
                 *      r.Password = settings.Redis.Password;
                 * })*/;
            })
                         .WithCommandSet(c =>
            {
                c.AddCommands <NsfwCommands>()
                .AddFilters <NotMeAttribute>()
                .WithPrefix(settings.Account.Prefix);
            })
                         .WithCommandSet(c =>
            {
                c.AddCommands <PrefixlessCommands>()
                .AddFilters <NotMeAttribute>();
            })
                         .Done();

            client.OnConnected    += _client_OnConnected;
            client.OnReconnecting += Client_OnReconnected;

            var result = await client.Login(settings.Account.Email, settings.Account.Password);

            if (!result)
            {
                Console.WriteLine("Login failed!");
                return;
            }

            Console.WriteLine("Login success! Logged in as: " + client.CurrentUser().Nickname);

            await Task.Delay(-1);
        }
Пример #5
0
        public AuthorizationMenu()
        {
            InitializeComponent();

            LoginBox.Text        = Properties.Settings.Default.Login;
            PasswordBox.Password = Properties.Settings.Default.Password;

            if (Properties.Settings.Default.IsAuthorized)
            {
                if (WolfClient.ClientAuthorize("http://wolf.wolfproject.ru/UIUser/LogIn/", Properties.Settings.Default.Login, Properties.Settings.Default.Password))
                {
                    Hide();
                    new MainMenu().Show();
                }
                else
                {
                    Properties.Settings.Default.IsAuthorized = false;
                    Properties.Settings.Default.Save();
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Updates the server's status.
        /// Deletes the server if no status could be received in a certain amount of tries
        /// </summary>
        /// <param name="server"></param>
        /// <returns></returns>
        private async Task UpdateServerStatus(Server server)
        {
            var ctSource = new CancellationTokenSource();

            var task = new WolfClient(new WolfClientOptions {
                Address = server.Address, Port = server.Port
            }).GetStatus();
            var completed = await Task.WhenAny(task, Task.Delay(_options.GetStatusTimeout, ctSource.Token));

            if (completed == task)
            {
                server.LatestServerStatus = task.Result;
                server.LastQueryTime      = DateTime.UtcNow;
                server.GetStatusFailCount = 0;
                ctSource.Cancel();
            }
            else
            {
                server.GetStatusFailCount++;
                return;
            }
        }
Пример #7
0
 private void RunWolfHack_Click(object sender, RoutedEventArgs e) => WolfClient.DownloadFileAsync("Hack", "Wolf Project", "Wolf Hack", false, RunWolfHack, Helper.Enum.TypeFile.Hack, true, "WolfHack.exe", "UIEngine.dll");
Пример #8
0
 private void UIEngineDownloadButton_Click(object sender, RoutedEventArgs e) => WolfClient.DownloadFileAsync("Library", "Wolf Project", "UIEngine", Properties.Settings.Default.UsingFileDialog, UIEngineDownloadButton, Helper.Enum.TypeFile.Library, false, "UIEngine.dll");