コード例 #1
0
 public virtual void RegisterUserDelete(RegisterUser entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdRegisterUserDelete(entity.ID);
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
コード例 #2
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            try
              {
            if (!Page.IsValid)
            {
              return;
            }

            RegisterUser regUser = new RegisterUser(Guid.NewGuid());
            regUser.LoginName = txtLoginName.Text;
            regUser.Name = txtUserFullName.Text;
            regUser.Sex = cmbSex.SelectedValue;
            regUser.BirthYear = txtBirthYear.Text;
            regUser.Phone = txtUserPhone.Text;
            regUser.Email = txtUserEmail.Text;
            regUser.Country = txtAddressCountry.Text;
            regUser.City = txtAddressCity.Text;
            regUser.PostCode = txtAddressPostCode.Text;
            regUser.Address = txtAddressStreet.Text;
            regUser.QualificationRef = cmbQualification.SelectedValue;
            regUser.NewsMail = cbxNewsMail.Checked;
            regUser.ReasonOfRegistration = txtReasonOfRegistration.Text;

            if (Context.User.Identity.IsAuthenticated)
            {
              NdiPrincipal principal = (NdiPrincipal) Context.User;
              if (!principal.OrganisationID.Equals(Guid.Empty))
              {
            regUser.OrganisationRef = principal.OrganisationID;
            regUser.Right = cmbUserRights.SelectedValue;
              }
            }

            IRegisterUserService srv = ServiceFactory.GetRegisterUserService();
            srv.RegisterUserInsert(regUser);

            Response.Redirect("RegisterFinish.aspx?from=user");
              }
              catch (Exception ex)
              {
            errorPanel.Exception = ex;
              }
        }
コード例 #3
0
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Fill datagrid with data
        /// </summary>
        // -------------------------------------------------------------------------------------
        private void FillDatagrid(DBGuid ID)
        {
            try
              {
            string sortColumn = "SentDate";
            int selectedRow = -1;

            // storing the previous sort order
            if (dtgMain.DataSource != null)
            {
              sortColumn = ((DataTable) dtgMain.DataSource).DefaultView.Sort;
            }

            // set filter
            RegisterUser filter = new RegisterUser(Guid.Empty);
            if (cmbStatusFilter.SelectedIndex > 0)
            {
              filter.Status = cmbStatusFilter.SelectedValue.ToString();
            }
            // retrieving data from BusinessServices
            IRegisterUserService srv = ServiceFactory.GetRegisterUserService();
            RegisterUserContainer allData = srv.RegisterUserSelectFiltered(filter);
            DataTable dt = allData.AllAsDatatable;
            dt.DefaultView.Sort = sortColumn;
            dtgMain.DataSource = dt;

            // locates the row specified by ID param
            if (!ID.IsNull)
            {
              BindingManagerBase bm = dtgMain.BindingContext[dtgMain.DataSource, dtgMain.DataMember];
              DataRow dr;
              for (int i = 0; i < bm.Count; i++)
              {
            dr = ((DataRowView) bm.Current).Row;
            //if (  ((DBGuid)dr["ID"]).Value.Equals(ID) )
            if (ID.Value.Equals(dr["ID"]))
            {
              selectedRow = i;
              break;
            }
            bm.Position += 1;
              }
            }

            // makes the row selected
            if (selectedRow <= ((DataTable) dtgMain.DataSource).DefaultView.Count && selectedRow > -1)
            {
              dtgMain.Select(selectedRow);
              dtgMain.CurrentRowIndex = selectedRow;
            }
            else if (((DataTable) dtgMain.DataSource).DefaultView.Count != 0)
            {
              dtgMain.Select(0);
            }

            // enabling or disabling the buttons according to record count. And is because of previous disable state.
            tbbDecide.Enabled = (((DataTable) dtgMain.DataSource).DefaultView.Count != 0);
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba a lista frissítése során.", ex);
              }
        }
コード例 #4
0
        public RegisterUserContainer RegisterUserSelectFiltered(RegisterUser filter)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            RegisterUserContainer result;
            DataSet entitySet = m_DataContext.ndihdRegisterUserSelectFiltered(
              filter.Name,
              filter.LoginName,
              filter.OrganisationRef,
              filter.Status);
            result = new RegisterUserContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
コード例 #5
0
        public bool RegisterUserReject(RegisterUser entity)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            if (entity.RejectComment.Length == 0)
              throw new ArgumentNullException("RegisterUser.RejectComment", "Az elutasítás indoklása nincs megadva.");

            // Logical checks:
            RegisterUser selected = base.RegisterUserSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik regisztrálandó felhasználó.");
            if (!selected.Status.Equals(RegistrationStatus.New))
              throw new ApplicationException("Csak új státuszú regisztráció bírálható el.");

            // Set properties
            selected.DecidedBy = Thread.CurrentPrincipal.Identity.Name;
            selected.DecidedDate = DBDateTime.Now;
            selected.Status = RegistrationStatus.Rejected;
            selected.RejectComment = entity.RejectComment;

            //set mail:
            Email mail = new Email(Guid.NewGuid());
            mail.Category = EmailCategory.UserRegistrationReject;
            mail.To = selected.Email;

            //Subject és body lekérdezése
            string body = "";
            string subject = "";
            IEmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.UserRegistrationReject);

            mail.Subject = subject;

            body = body.Replace("<FULL_USER_NAME>", selected.Name);
            body = body.Replace("<LOGIN_NAME>", selected.LoginName);
            body = body.Replace("<REJECT_COMMENT>", entity.RejectComment);
            mail.MailBody = body;

            // Save data to database
            EmailService emailSrv = new EmailService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              base.RegisterUserUpdate(selected);
              emailSrv.EmailInsert(mail);
              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            // Sending mail:
            try
            {
              emailSrv.EmailSend(mail.ID);
            }
            catch (Exception ex)
            {
              ExceptionManager.Publish(ex);
              return false;
            }

            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("RegisterUserID", entity.ID.ToString()),
              new EventParameter("LoginName", selected.LoginName)
              );
            TraceCallReturnEvent.Raise();
            return true;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("RegisterUserID", entity.ID.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
コード例 #6
0
        public new void RegisterUserInsert(RegisterUser entity)
        {
            // Check permission: anybody
              TraceCallEnterEvent.Raise();
              try
              {
            if (entity.LoginName.Length == 0)
              throw new ArgumentNullException("RegisterUser.LoginName",
                                          "A regisztrálandó felhasználó bejelentkezési neve nincs megadva.");
            if (entity.Name.Length == 0)
              throw new ArgumentNullException("RegisterUser.Name", "A regisztrálandó felhasználó neve nincs megadva.");
            if (entity.Sex.Length == 0)
              throw new ArgumentNullException("RegisterUser.Sex", "A regisztrálandó felhasználó neme nincs megadva.");
            if (entity.BirthYear.Length == 0)
              throw new ArgumentNullException("RegisterUser.BirthYear",
                                          "A regisztrálandó felhasználó születési éve nincs megadva.");
            if (entity.Email.Length == 0)
              throw new ArgumentNullException("RegisterUser.Email",
                                          "A regisztrálandó felhasználó e-mail címe nincs megadva.");
            if (entity.QualificationRef.Length == 0)
              throw new ArgumentNullException("RegisterUser.QualificationRef",
                                          "A regisztrálandó felhasználó legmagasabb iskolai végzettsége nincs megadva.");
            if (entity.ReasonOfRegistration.Length == 0)
              throw new ArgumentNullException("RegisterUser.ReasonOfRegistration",
                                          "Az adatbázis használatának célja nincs megadva.");

            // Logical checks
            UserService userService = new UserService(m_DataContext);
            if (userService.UserCheckLoginName(entity.LoginName))
              throw new ApplicationException("A megadott bejelentkezési név már foglalt. Kérem válasszon másikat.");

            if (entity.OrganisationRef.IsNull)
            {
              entity.Right = UserRights.NonOrganisation;
            }
            else
            {
              string writerRole = entity.OrganisationRef.Value.ToString() + ".Writer";
              PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole);
              permWriter.Demand();
              if (entity.Right.Length == 0) entity.Right = UserRights.Read;
            }

            entity.SentDate = DBDateTime.Now;
            entity.Status = RegistrationStatus.New;

            base.RegisterUserInsert(entity);
            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("RegisterUserID", entity.ID.ToString()),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("RegisterUserID", entity.ID.ToString()),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
コード例 #7
0
        public bool RegisterUserAccept(RegisterUser entity)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            if (entity.LoginName.Length == 0)
              throw new ArgumentNullException("RegisterUser.LoginName",
                                          "A regisztrálandó felhasználó bejelentkezési neve nincs megadva.");
            if (entity.Name.Length == 0)
              throw new ArgumentNullException("RegisterUser.Name", "A regisztrálandó felhasználó neve nincs megadva.");
            if (entity.Sex.Length == 0)
              throw new ArgumentNullException("RegisterUser.Sex", "A regisztrálandó felhasználó neme nincs megadva.");
            if (entity.BirthYear.Length == 0)
              throw new ArgumentNullException("RegisterUser.BirthYear",
                                          "A regisztrálandó felhasználó születési éve nincs megadva.");
            if (entity.Email.Length == 0)
              throw new ArgumentNullException("RegisterUser.Email",
                                          "A regisztrálandó felhasználó e-mail címe nincs megadva.");
            if (entity.QualificationRef.Length == 0)
              throw new ArgumentNullException("RegisterUser.QualificationRef",
                                          "A regisztrálandó felhasználó legmagasabb iskolai végzettsége nincs megadva.");
            if (entity.ReasonOfRegistration.Length == 0)
              throw new ArgumentNullException("RegisterUser.ReasonOfRegistration",
                                          "Az adatbázis használatának célja nincs megadva.");
            if (entity.Right.Length == 0)
              throw new ArgumentNullException("RegisterUser.Right", "A jogosultság nincs megadva.");

            // Logical checks:
            RegisterUser selected = base.RegisterUserSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik regisztrálandó felhasználó.");
            if (!selected.Status.Equals(RegistrationStatus.New))
              throw new ApplicationException("Csak új státuszú regisztráció bírálható el.");

            // Set properties
            entity.SentDate = selected.SentDate;
            entity.DecidedBy = Thread.CurrentPrincipal.Identity.Name;
            entity.DecidedDate = DBDateTime.Now;
            entity.Status = RegistrationStatus.Accepted;

            User newUser = new User(entity.LoginName);
            string generatedPassword = Password.Generate();
            newUser.Password = Password.ComputeHash(generatedPassword);

            newUser.OrganisationRef = entity.OrganisationRef;
            newUser.Name = entity.Name;
            newUser.Sex = entity.Sex;
            newUser.BirthYear = entity.BirthYear;
            newUser.Phone = entity.Phone;
            newUser.Email = entity.Email;
            newUser.PostCode = entity.PostCode;
            newUser.City = entity.City;
            newUser.Address = entity.Address;
            newUser.Country = entity.Country;
            newUser.QualificationRef = entity.QualificationRef;
            newUser.ReasonOfRegistration = entity.ReasonOfRegistration;
            newUser.Right = entity.Right;
            newUser.IsActive = true;
            newUser.NewsMail = entity.NewsMail;
            newUser.MustChangePassword = true;
            newUser.LockedOut = false;
            newUser.FailedAttemptCount = 0;

            //set mail:
            Email mail = new Email(Guid.NewGuid());
            mail.Category = EmailCategory.UserRegistrationAccept;
            mail.To = entity.Email;

            //Subject és body lekérdezése
            string body = "";
            string subject = "";
            EmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.UserRegistrationAccept);

            mail.Subject = subject;

            body = body.Replace("<FULL_USER_NAME>", entity.Name);
            body = body.Replace("<LOGIN_NAME>", entity.LoginName);
            body = body.Replace("<PASSWORD>", generatedPassword);
            mail.MailBody = body;

            // Save data to database
            EmailService emailSrv = new EmailService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              UserServiceBase userSrv = new UserServiceBase(m_DataContext);
              userSrv.UserInsert(newUser);
              base.RegisterUserUpdate(entity);
              emailSrv.EmailInsert(mail);
              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            // Sending mail:
            try
            {
              emailSrv.EmailSend(mail.ID);
            }
            catch (Exception ex)
            {
              ExceptionManager.Publish(ex);
              return false;
            }

            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("RegisterUserID", entity.ID.ToString()),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise();
            return true;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("RegisterUserID", entity.ID.ToString()),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
コード例 #8
0
        private void AcceptRegistration()
        {
            IRegisterUserService regUsrSrv = ServiceFactory.GetRegisterUserService();
              RegisterUser regUsr = new RegisterUser(CurrentID);
              regUsr.LoginName = txtLoginName.Text;
              regUsr.OrganisationRef = m_OrganisationId;
              regUsr.Name = txtUserName.Text;
              if (rbtMan.Checked) regUsr.Sex = "F";
              if (rbtWoman.Checked) regUsr.Sex = "N";
              regUsr.BirthYear = txtBirthYear.Text;
              if (txtPhone.Text.Length > 0)
            regUsr.Phone = txtPhone.Text;
              regUsr.Email = txtEmail.Text;
              if (txtPostCode.Text.Length > 0)
            regUsr.PostCode = txtPostCode.Text;
              if (txtCity.Text.Length > 0)
            regUsr.City = txtCity.Text;
              if (txtAddress.Text.Length > 0)
            regUsr.Address = txtAddress.Text;
              if (txtCountry.Text.Length > 0)
            regUsr.Country = txtCountry.Text;
              regUsr.QualificationRef = cmbQualification.SelectedValue.ToString();
              regUsr.ReasonOfRegistration = txtReasonOfRegistration.Text;
              if (m_OrganisationId.IsNull)
              {
            regUsr.Right = UserRights.NonOrganisation;
              }
              else
              {
            regUsr.Right = cmbRight.SelectedValue.ToString();
              }
              regUsr.NewsMail = cbxNewsmail.Checked;
              regUsr.RejectComment = txtRejectComment.Text;

              if (!regUsrSrv.RegisterUserAccept(regUsr))
              {
            MessageBox.Show("Az elfogadás megtörtént, de az értesítõ levél kiküldése nem sikerült.",
                        "NDI HelpDesk Administrator", MessageBoxButtons.OK, MessageBoxIcon.Warning);
              }
        }
コード例 #9
0
        private void RejectRegistration()
        {
            IRegisterUserService regUsrSrv = ServiceFactory.GetRegisterUserService();
              RegisterUser regUsr = new RegisterUser(CurrentID);
              regUsr.RejectComment = txtRejectComment.Text;

              if (!regUsrSrv.RegisterUserReject(regUsr))
              {
            MessageBox.Show("Az elutasítás megtörtént, de az értesítõ levél kiküldése nem sikerült.",
                        "NDI HelpDesk Administrator", MessageBoxButtons.OK, MessageBoxIcon.Warning);
              }
        }
コード例 #10
0
ファイル: RegisterUser.cs プロジェクト: bmadarasz/ndihelpdesk
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public RegisterUser(RegisterUser origInstance)
     : base(origInstance)
 {
 }
コード例 #11
0
ファイル: RegisterUser.cs プロジェクト: bmadarasz/ndihelpdesk
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="IDVal">Value of 'uID' field</param>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public RegisterUser(DBGuid IDVal,
                 RegisterUser origInstance)
     : base(IDVal, origInstance)
 {
 }
コード例 #12
0
 public virtual void RegisterUserUpdate(RegisterUser entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       int count;
       m_DataContext.ndihdRegisterUserUpdate(entity.ID,
                                         entity.LoginName,
                                         entity.OrganisationRef,
                                         entity.Name,
                                         entity.Sex,
                                         entity.BirthYear,
                                         entity.Phone,
                                         entity.Email,
                                         entity.PostCode,
                                         entity.City,
                                         entity.Address,
                                         entity.Country,
                                         entity.QualificationRef,
                                         entity.ReasonOfRegistration,
                                         entity.Right,
                                         entity.NewsMail,
                                         entity.Status,
                                         entity.SentDate,
                                         entity.DecidedBy,
                                         entity.DecidedDate,
                                         entity.RejectComment, out count);
       if (count == 0) throw new ServiceUpdateException();
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
コード例 #13
0
 public virtual RegisterUser RegisterUserSelect(DBGuid IDVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     RegisterUser result = null;
     DataSet entitySet = m_DataContext.ndihdRegisterUserSelect(IDVal);
     if (entitySet.Tables[0].Rows.Count != 0)
     {
       result = new RegisterUser(entitySet);
     }
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }