Example #1
0
 public static RequestMethods GetRequestMethods()
 {
     lock (locker)
     {
         return(methods ?? (methods = new RequestMethods()));
     }
 }
Example #2
0
        public static BitmapSource ImageSource(int productID)
        {
            RequestMethods methods = RequestMethods.GetRequestMethods();

            byte[] bytes = methods.GetPhoto(productID);
            return((BitmapSource) new ImageSourceConverter().ConvertFrom(bytes));
        }
Example #3
0
 public AuctionPageViewModel()
 {
     methods                  = RequestMethods.GetRequestMethods();
     Requester.OnTimer       += TimerSetter;
     Requester.OnTradeupdate += TradeUpdate;
     SetActualTrade();
     ClientAuction.IsOpenMain = true;
 }
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                RequestMethods methods     = RequestMethods.GetRequestMethods();
                Product        nextProduct = await methods.GetNextProductAsync(nextTrade.ProductId);

                ProductVisual visual = new ProductVisual();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #5
0
 public static void ClearConnect()
 {
     if (Stream.CanWrite)
     {
         RequestMethods methods = RequestMethods.GetRequestMethods();
         methods.DisconnectServer();
         Key = false;
     }
     if (Stream != null)
     {
         Stream.Close();//отключение потока
     }
     if (Client != null)
     {
         Client.Close();//отключение клиента
     }
 }
Example #6
0
        private async void Regisration_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!IsValid(Email.Text))
                {
                    Warning.Text = "Неверный email";
                    return;
                }
                if (Regex.IsMatch(FirstPass.Password, @"[^a-zA-Z0-9]+"))
                {
                    Warning.Text = "Неверный пароль";
                    return;
                }
                //EnteringWindow entering = (EnteringWindow)Owner;
                if (!ServerConnector.IsConnectionOpened)
                {
                    ServerConnector.ConnectToServer();
                }
                if (ServerConnector.IsConnectionOpened)
                {
                    RequestMethods methods = RequestMethods.GetRequestMethods();
                    Account        account = new Account(RegLogin.Text, Account.GetHashCode(FirstPass.Password), Email.Text);
                    bool           result  = await methods.RegistrationAsync(account);

                    if (!result)
                    {
                        MessageBox.Show("Такой аккаунт уже существует", "Ошибка", MessageBoxButton.OK);
                    }
                    else
                    {
                        //((EnteringWindowViewModel)Owner).EnterData(account.Login, account.Password);
                        Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка");
            }
        }
        private async void AddProd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!System.IO.File.Exists(ImagePath.Text))
                {
                    MessageBox.Show("Файл не найден", "Ошибка", MessageBoxButton.OK);
                }
                else if (Regex.IsMatch(Price.Text, @"[^0-9.,]+"))
                {
                    MessageBox.Show("Цена задана не верно", "Ошибка", MessageBoxButton.OK);
                }
                else
                {
                    RequestMethods methods = RequestMethods.GetRequestMethods();
                    Product        product = new Product(ImagePath.Text, float.Parse(Price.Text, System.Globalization.CultureInfo.InvariantCulture), Name.Text, rtbDescription.Text, account.AccountId);
                    byte[]         imageBt = File.ReadAllBytes(ImagePath.Text);
                    int            id      = await methods.AddProductAsync(product);

                    bool isAdded = await methods.SetProductPhotoAsync(id, imageBt);

                    if (isAdded)
                    {
                        MessageBox.Show("Лот добавлен", "Уведомление");
                    }
                    else
                    {
                        MessageBox.Show("Лот не добавлен", "Уведомление");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка");
            }
        }
Example #8
0
 public AdminPanel()
 {
     methods = RequestMethods.GetRequestMethods();
     InitializeComponent();
     SetProductList();
 }
Example #9
0
 public Requester(List <Response> responseList)
 {
     this.responseList = responseList;
     methods           = RequestMethods.GetRequestMethods();
 }