Ejemplo n.º 1
0
        private void TryToLogin()
        {
            try
            {
                if (String.IsNullOrEmpty(this.UserName.Text))
                {
                    return;
                }

                _user = _formsService.UsersService.LoadUserByName(this.UserName.Text);

                if (_user.HasEmptyPassword && this.Password.Text.Equals(""))
                {
                    _formsService.ActivateForm(FormTypeCodes.NewPasswordForm);
                    this.lblError.Text = String.Empty;
                    return;
                }

                if (String.IsNullOrEmpty(this.Password.Text))
                {
                    this.lblError.Text = String.Format("Morate uneti lozinku.");
                    return;
                }

                string inputHash = _authorizationService.HashPassword(this.Password.Text);

                if (inputHash.Equals(_user.PasswordHash))
                {
                    MainForm mainForm = (MainForm)_formsService.GetFormByCode(FormTypeCodes.MainForm);
                    mainForm.loggedUser = _user;
                    _formsService.ActivateForm(FormTypeCodes.MainForm);

                    _formsService.ResetFormTextBoxes(this.Controls);
                    this.lblError.Text = String.Empty;
                    return;
                }

                this.lblError.Text = String.Format("Uneta lozinka nije ispravna.");
            }
            catch (UserNotFoundException ex)
            {
                this.lblError.Text = String.Format("{0}'{1}'.", ex.Message, this.UserName.Text);
            }
            catch (Exception ex)
            {
                BusinessServiceBase.logger.Error(ex);
                this.lblError.Text = "Došlo je do sistemske greške. Kontaktirajte administratora.";
            }
        }
Ejemplo n.º 2
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.passwordTextBox1.Text) || String.IsNullOrEmpty(this.passwordTextBox2.Text))
            {
                return;
            }
            if (!this.passwordTextBox1.Text.Equals(this.passwordTextBox2.Text))
            {
                return;
            }
            if (this.passwordTextBox1.Text.Length < AuthorizationBusinessService.PASSWORD_CHAR_MIN)
            {
                return;
            }

            this.lblError.Text = String.Empty;

            LoginForm loginForm = (LoginForm)_formsService.GetFormByCode(FormTypeCodes.LoginForm);

            string   hash     = new AuthorizationBusinessService().HashPassword(this.passwordTextBox1.Text);
            MainForm mainForm = (MainForm)_formsService.GetFormByCode(FormTypeCodes.MainForm);

            mainForm.loggedUser = _formsService.UsersService.SaveUserPassword(loginForm.GetUserName.Text, hash);

            _formsService.ResetFormTextBoxes(this.Controls);
            _formsService.ActivateForm(FormTypeCodes.MainForm);
            _formsService.ResetFormTextBoxes(loginForm.Controls);
        }
Ejemplo n.º 3
0
 private void btnLogout_Click(object sender, EventArgs e)
 {
     loggedUser = null;
     _formsService.ActivateForm(FormTypeCodes.LoginForm);
 }
Ejemplo n.º 4
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     lblError.Text = String.Empty;
     _formsService.ResetFormTextBoxes(this.Controls);
     _formsService.ActivateForm(FormTypeCodes.LoginForm);
 }
Ejemplo n.º 5
0
 private void btnReturnToMain_Click(object sender, EventArgs e)
 {
     _formsService.ActivateForm(FormTypeCodes.MainForm);
 }
Ejemplo n.º 6
0
        private void CreateOrUpdateDocument()
        {
            try
            {
                this.lblError.Text = String.Empty;
                if (String.IsNullOrEmpty(this.txtBoxTitle.Text))
                {
                    return;
                }

                if (documentDto == null)
                {
                    if (!_fileDetailsKvp.HasValue)
                    {
                        this.lblError.Text = "Morate priložiti fajl.";
                        return;
                    }

                    documentDto = new DocumentDTO();
                }

                documentDto.Title    = txtBoxTitle.Text;
                documentDto.Keywords = new List <KeywordDTO>();

                foreach (object obj in boxKeywords.Items)
                {
                    string value = obj as string;
                    if (!String.IsNullOrEmpty(value))
                    {
                        documentDto.Keywords.Add(new KeywordDTO()
                        {
                            Name = value
                        });
                    }
                }

                documentDto.DocumentShares = _sharedWith;

                if (documentDto.Id > 0)
                {
                    _formsService.DocumentsService.UpdateDocumentData(documentDto, _formsService.GetLoggedUser().Id);
                }
                else
                {
                    documentDto.Extension = _fileDetailsKvp.Value.Value;
                    documentDto           = _formsService.DocumentsService.SaveNewDocument(documentDto, _formsService.GetLoggedUser().Id);

                    string newPath = _formsService.DocumentsService.AddNewDocumentVersion(documentDto);
                    _filesService.SaveFileToServer(_fileDetailsKvp.Value.Key, newPath);
                }

                _formsService.ActivateForm(FormTypeCodes.MainForm);
                documentDto = null;
            }
            catch (Exception ex)
            {
                BusinessServiceBase.logger.Error(ex.Message);
                this.lblError.Text = "Došlo je do sistemske greške. Kontaktirajte administratora.";
                documentDto        = null;
            }
        }