Ejemplo n.º 1
0
        private void GoIntoRegistrationButton_Click(object sender, RoutedEventArgs e)
        {
            System.Xml.XmlDictionaryReaderQuotas quotas = new System.Xml.XmlDictionaryReaderQuotas()
            {
                MaxArrayLength = int.MaxValue
            };
            NetTcpBinding binding = new NetTcpBinding()
            {
                MaxReceivedMessageSize = int.MaxValue,
                ReaderQuotas           = quotas
            };

            binding.Security.Mode = SecurityMode.None;
            Contract_Client contract = new Contract_Client(binding, new EndpointAddress("net.tcp://" + AppConfiguration.ConfigurationWorker.ServerIP + ":" + AppConfiguration.ConfigurationWorker.ServerPort.ToString()));

            try
            {
                if (contract.Registrate(LoginTextBox.Text, PasswordTextBox.Text))
                {
                    MessageBox.Show("Пользователь создан");
                }
                else
                {
                    MessageBox.Show("Не удалось зарегистрировать пользователя. Вероятно, пользователь с таким логином уже есть.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            contract.Close();
        }
Ejemplo n.º 2
0
        private void AuthentificationButton_Click(object sender, RoutedEventArgs e)
        {
            System.Xml.XmlDictionaryReaderQuotas quotas = new System.Xml.XmlDictionaryReaderQuotas()
            {
                MaxArrayLength = int.MaxValue
            };
            NetTcpBinding binding = new NetTcpBinding()
            {
                MaxReceivedMessageSize = int.MaxValue,
                ReaderQuotas           = quotas
            };

            binding.Security.Mode = SecurityMode.None;
            Contract_Client contract = new Contract_Client(binding, new EndpointAddress("net.tcp://" + AppConfiguration.ConfigurationWorker.ServerIP + ":" + AppConfiguration.ConfigurationWorker.ServerPort.ToString()));

            try
            {
                if (contract.TryAuthentificate(LoginTextBox.Text, PasswordTextBox.Text))
                {
                    new MainMenu.MainMenuModel(contract);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Неверный логин/пароль");
                    contract.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

                if (contract.State != CommunicationState.Faulted)
                {
                    contract.Close();
                }
            }
        }
Ejemplo n.º 3
0
        public MainMenuModel(Contract_Client contract_Client)
        {
            this.contract = contract_Client;

            removeAttachmentCommand   = new RelayCommand((x) => { RemoveAttachment((AttachmentIcon)x); });
            downloadAttachmentCommand = new RelayCommand((x) => { DownloadAttachment(((AttachmentIcon)x)._attachmentData.id); });
            addAttachmentCommand      = new RelayCommand((x) => { AddAttachment(new ShortRequestWithAttachments()
                {
                    attachmentList = new List <ShortAttachmentData>(), Request = new Request()
                }); });
            addAttachmentToWindowCommand = new RelayCommand((x) =>
            {
                AddAttachment(new ShortRequestWithAttachments()
                {
                    attachmentList = new List <ShortAttachmentData>(), Request = new Request()
                });
                AttachmentsList = new ObservableCollection <AttachmentIcon>(contract.GetAttachmentsList().ShortAttachmentList.Select(i => new AttachmentIcon(i, false)));
                attachmentsWindow.AttachmentsField.GetBindingExpression(ItemsControl.ItemsSourceProperty).UpdateTarget();                //its working!!!
            });

            ActualRequestsList = new ObservableCollection <RequestPanel>();
            this.middlePage    = new TasksPage()
            {
                DataContext = this
            };
            InitalizeMenuButtons();
            mainMenu = new MainMenu()
            {
                DataContext = this
            };
            programmTrayMenu = new TrayMenu(mainMenu);


            mainMenu.Show();
            InitalizeIcon();
        }