Пример #1
0
        public HomeViewModel()
        {
            _homeApiClient = new HomeClient();
            _voteClient    = new VoteClient();

            var mainVm = ServiceLocator.Current.GetInstance <MainViewModel>();

            if (mainVm.LoggedIn)
            {
                Task.Run(async() => { await GetVotes(); });
            }
            else
            {
                mainVm.OnLogin += async(e, u) => await GetVotes();
            }

            ProceedCommand    = new RelayCommand(DoProceed, CanProceed);
            RefreshCommand    = new RelayCommand(async() => await GetVotes(), CanRefresh);
            ClickErrorCommand = new RelayCommand(DoError);

            VoteCollection    = new ObservableRangeCollection <BlockchainViewModel>();
            VoteSource        = CollectionViewSource.GetDefaultView(VoteCollection);
            VoteSource.Filter = VoteFilter;
            VoteSource.SortDescriptions.Add(new SortDescription("ExpiryDate", ListSortDirection.Ascending));
        }
        private void ConnectUser()
        {
            newClient = new HomeClient(txtAddress.Text, port, txtUserName.Text, Color.FromName(cmbColor.Text));
            if (newClient.ServerError)
            {
                DialogResult dr = MessageBox.Show("Error! Please check the server activity.", "Server Error!",
                                                  MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                if (dr == DialogResult.Retry)
                {
                    ConnectUser();
                    return;
                }
                else
                {
                    newClient              = null;
                    btnFinish.Enabled      = true;
                    btnDisconnect.Enabled  = false;
                    txtSendMessege.Enabled = false;
                    txtAddress.Enabled     = true;
                    txtPort.Enabled        = true;
                    txtUserName.Enabled    = true;
                    cmbColor.Enabled       = true;
                    return;
                }
            }
            newClient.receiveMessege += AddMessegesHandler;
            newClient.ReceiveMesseges();
            MsgStatus msg = new MsgStatus(newClient.GetUser, newClient.GetUser.UserStatus);

            newClient.SendMessege(msg);
            txtSendMessege.Enabled = true;
            this.btnSend.Enabled   = txtSendMessege.Text != "";
        }
        private void SingUpUser(object o, EventArgs e)
        {
            newClient = new HomeClient(txtAddress.Text, port, txtUserName.Text, Color.FromName(cmbColor.Text), Operation.SingUp);
            newClient.existingAccount += ExistingAccount;
            newClient.receiveMessege  += AddMessegesHandler;

            if (newClient.ServerError)
            {
                MessageBox.Show("Error! Please check the server activity.", "Server Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                ResultForErorr();
                return;
            }
            if (newClient.IsExist.ErrorExists == false)
            {
                MsgStatus msg = new MsgStatus(newClient.GetUser, newClient.GetUser.UserStatus);
                newClient.SendMessege(msg);
            }
            btnSingUp.Enabled      = false;
            btnLogIn.Enabled       = false;
            txtSendMessege.Enabled = true;
            btnSend.Enabled        = true;
            txtUserName.Enabled    = false;
            cmbColor.Enabled       = false;
            btnLogOut.Enabled      = true;
        }
Пример #4
0
 public HomeController(ILogger <HomeController> logger,
                       HomeClient homeClient,
                       AccountClient accountClient)
 {
     _logger        = logger;
     _homeClient    = homeClient;
     _accountClient = accountClient;
 }
Пример #5
0
        protected internal async Task <ICollection <VaultTemplate> > GetTemplatesNew(long cloudId)
        {
            //var scope = Request.GetOwinContext().GetAutofacLifetimeScope();
            var templates = await Task.Run(() => HomeClient.GetProjectTemplates(_vaultTemplateService)); // HomeClient.GetProjectTemplatesNew(scope);

            //var templates = JsonConvert.DeserializeObject<List<VaultTemplate>>(templatesRes.Content);
            return(templates);
        }
 public HistoryClient(HttpClient client)
 {
     Empire       = new EmpireClient(client);
     EventGuesser = new EventGuesserClient(client);
     Home         = new HomeClient(client);
     User         = new UserClient(client);
     Test         = new TestClient(client);
     Topic        = new TopicClient(client);
 }
        private void LogInUser(object sender, EventArgs e)
        {
            newClient = new HomeClient(txtAddress.Text, port, txtUserName.Text, Color.FromName(cmbColor.Text), Operation.LogIn);
            newClient.existingAccount += ExistingAccount;
            newClient.receiveMessege  += AddMessegesHandler;

            if (newClient.ServerError)
            {
                DialogResult dr = MessageBox.Show("Error! Please check the server activity.", "Server Error!",
                                                  MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                if (dr == DialogResult.Retry)
                {
                    LogInUser(sender, e);
                    return;
                }
                else
                {
                    newClient              = null;
                    btnLogIn.Enabled       = true;
                    btnLogOut.Enabled      = false;
                    txtSendMessege.Enabled = false;
                    txtAddress.Enabled     = true;
                    txtPort.Enabled        = true;
                    txtUserName.Enabled    = true;
                    cmbColor.Enabled       = true;
                    return;
                }
            }

            txtSendMessege.Enabled = true;
            txtAddress.Enabled     = false;
            txtPort.Enabled        = false;
            txtUserName.Enabled    = false;
            cmbColor.Enabled       = false;
            txtUserName.Enabled    = false;
            cmbColor.Enabled       = false;
            btnLogOut.Enabled      = true;
            btnLogIn.Enabled       = false;
            btnSingUp.Enabled      = false;

            if (newClient.IsExist.ErrorExists == false)
            {
                MsgStatus msg = new MsgStatus(newClient.GetUser, newClient.GetUser.UserStatus);
                newClient.SendMessege(msg);
                this.txtSendMessege.Enabled = true;
                this.btnSend.Enabled        = txtSendMessege.Text != "";
            }
        }
 private void ResultForErorr()
 {
     if (InvokeRequired)
     {
         Invoke(new Action(ResultForErorr));
         return;
     }
     newClient              = null;
     btnLogIn.Enabled       = true;
     btnLogOut.Enabled      = false;
     txtSendMessege.Enabled = false;
     txtAddress.Enabled     = true;
     txtPort.Enabled        = true;
     txtUserName.Enabled    = true;
     cmbColor.Enabled       = true;
 }