protected void ShowForumThreadGrid(DataGrid dataGrid,
                                       int index, string sort, string order, Guid groupGuid)
        {
            dataGrid.PageSize = Helpers.GetPageSize("PageSize.ForumThreadList");

              // Get query result from database
              ForumThread filter = new ForumThread(Guid.NewGuid());
              filter.FilterOnIsactive = 1;
              filter.ForumGroupRef = groupGuid;

              IForumThreadService srv = ServiceFactory.GetForumThreadService();
              ForumThreadContainer selected = srv.ForumThreadSelectFiltered(filter);

              if (selected.AllCount > 0)
              {
            dataGrid.Visible = true;
            lblNotFound.Visible = false;
              }
              else
              {
            dataGrid.Visible = false;
            lblNotFound.Visible = true;
            return;
              }

              ArrayList sortableList = null;
              // Sort if necessary
              if (sort == null)
              {
            sortableList = selected.All.Items;
              }
              else
              {
            if (String.Compare(order, "Ascending", true) == 0)
            {
              sortableList = selected.All.SortBy(sort, true);
            }
            else if (String.Compare(order, "Descending", true) == 0)
            {
              sortableList = selected.All.SortBy(sort, false);
            }
            else
            {
              sortableList = selected.All.SortBy(sort);
            }
              }

              // Bind list to datagrid control
              dataGrid.CurrentPageIndex = index;
              dataGrid.CurrentSortExpression = sort;
              dataGrid.CurrentSortOrder = order;
              dataGrid.DataSource = sortableList;
              dataGrid.DataBind();
        }
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            try
              {
            string groupId = Request["groupId"];
            Guid groupGuid = new Guid(groupId);

            ForumThread forumThread = new ForumThread(Guid.NewGuid());
            forumThread.Name = txtName.Text;

            // Modification HP060111 Begin
            // Replacing line ends

            string desc = txtDescription.Text;
            string newLine = "\r\n";

            desc = desc.Replace(newLine, "<br/>");
            forumThread.Description = desc;

            // Modification HP060111 End

            forumThread.ForumGroupRef = groupGuid;
            if (!Context.User.Identity.IsAuthenticated)
            {
              forumThread.CreatedBy = txtCreatedBy.Text;
            }
            forumThread.IsActive = true;

            IForumThreadService srv = ServiceFactory.GetForumThreadService();
            srv.ForumThreadInsert(forumThread);

            Response.Redirect("ForumThreadList.aspx?groupId=" + groupId);
              }
              catch (Exception ex)
              {
            errorPanel.Exception = ex;
              }
        }
 public virtual void ForumThreadUpdate(ForumThread entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       int count;
       m_DataContext.ndihdForumThreadUpdate(entity.ID,
                                        entity.Name,
                                        entity.Description,
                                        entity.CreatedBy,
                                        entity.CreatedDate,
                                        entity.IsActive,
                                        entity.ForumGroupRef, 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;
       }
 }
 public virtual ForumThread ForumThreadSelect(DBGuid IDVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     ForumThread result = null;
     DataSet entitySet = m_DataContext.ndihdForumThreadSelect(IDVal);
     if (entitySet.Tables[0].Rows.Count != 0)
     {
       result = new ForumThread(entitySet);
     }
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
 public virtual void ForumThreadInsert(ForumThread entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdForumThreadInsert(entity.ID,
                                        entity.Name,
                                        entity.Description,
                                        entity.CreatedBy,
                                        entity.CreatedDate,
                                        entity.IsActive,
                                        entity.ForumGroupRef);
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
 public virtual void ForumThreadDelete(ForumThread entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdForumThreadDelete(entity.ID);
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
Example #7
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="IDVal">Value of 'uID' field</param>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public ForumThread(DBGuid IDVal,
                ForumThread origInstance)
     : base(IDVal, origInstance)
 {
 }
Example #8
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public ForumThread(ForumThread origInstance)
     : base(origInstance)
 {
 }
        public new void ForumThreadInsert(ForumThread entity)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            // check required fields:
            if (entity.ID.IsNull)
              throw new ArgumentNullException("ForumThread.ID", "A fórum szál azonosítója nincs megadva.");
            if (entity.Name.Length == 0)
              throw new ArgumentNullException("ForumThread.Name", "A fórum szál neve nincs megadva.");
            if (entity.Description.Length == 0)
              throw new ArgumentNullException("ForumThread.Description", "A fórum szál leírása nincs megadva.");
            if (entity.ForumGroupRef.IsNull)
              throw new ArgumentNullException("ForumThread.ForumGroupRef", "A fórum téma azonosítója nincs megadva.");

            // logical checks:
            ForumGroupService groupSrv = new ForumGroupService();
            ForumGroup group = groupSrv.ForumGroupSelect(entity.ForumGroupRef);
            if (group == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik fórum téma.");
            if (!group.IsActive)
              throw new ApplicationException("A fórum téma nem aktív.");

            // check permission:
            if (!group.VisibleForVisitor)
            {
              PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
              PrincipalPermission permAdmin =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permReg.Union(permAdmin).Demand();
            }

            // save data:
            entity.CreatedDate = DBDateTime.Now;
            if (Thread.CurrentPrincipal.Identity.IsAuthenticated)
            {
              entity.CreatedBy = Thread.CurrentPrincipal.Identity.Name;
            }
            else
            {
              if (entity.CreatedBy.Length == 0)
              {
            entity.CreatedBy = "Anonymous";
              }
            }
            base.ForumThreadInsert(entity);

            BusinessAuditEvent.Success(
              new EventParameter("ForumThreadID", entity.ID.ToString()),
              new EventParameter("ForumThreadName", entity.Name)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ForumThreadID", entity.ID.ToString()),
              new EventParameter("ForumThreadName", entity.Name)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public new void ForumThreadUpdate(ForumThread entity)
        {
            // Check permission: Admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            if (entity.Name.Length == 0)
              throw new ArgumentNullException("ForumThread.Name", "A fórum szál neve nincs megadva.");
            if (entity.Description.Length == 0)
              throw new ArgumentNullException("ForumThread.Description", "A fórum szál leírása nincs megadva.");

            // Logical checks
            ForumThread selected = base.ForumThreadSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik fórum szál.");

            // Save data
            selected.IsActive = entity.IsActive;
            selected.Name = entity.Name;
            selected.Description = entity.Description;

            base.ForumThreadUpdate(selected);

            BusinessAuditEvent.Success(
              new EventParameter("ForumThreadID", entity.ID.ToString()),
              new EventParameter("ForumThreadName", entity.Name)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ForumThreadID", entity.ID.ToString()),
              new EventParameter("ForumThreadName", entity.Name)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
 public ForumThreadContainer ForumThreadSelectFiltered(ForumThread filter)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     ForumThreadContainer result;
     DataSet entitySet = m_DataContext.ndihdForumThreadSelectFiltered(
       filter.Name,
       filter.ForumGroupRef,
       filter.FilterOnLastItemFrom,
       filter.FilterOnLastItemTo,
       filter.FilterOnIsactive);
     result = new ForumThreadContainer(entitySet.Tables[0]);
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
        /// <summary>
        /// Fill datagrid with data
        /// </summary>
        private void FillDatagrid(DBGuid ID)
        {
            try
              {
            string sSortColumn = "Name";
            int nSelectedRow = -1;

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

            // Set filter
            ForumThread filter = new ForumThread(Guid.Empty);
            filter.FilterOnIsactive = DBInt.Null;
            if (cmbStatus.SelectedIndex > 0)
            {
              bool bIsActive = (cmbStatus.SelectedValue.ToString() == "1" ? true : false);
              filter.FilterOnIsactive = (DBInt) Convert.ToInt32(bIsActive);
              filter.IsActive = bIsActive;
            }
            if (cmbForumGroup.SelectedIndex > 0)
            {
              filter.ForumGroupRef = new DBGuid(new Guid(cmbForumGroup.SelectedValue.ToString()));
            }
            if (dtpLastItemFrom.Checked)
            {
              filter.FilterOnLastItemFrom = new DBDateTime(dtpLastItemFrom.Value);
            }
            if (dtpLastItemTo.Checked)
            {
              DBDateTime dateTo = new DBDateTime(dtpLastItemTo.Value);
              filter.FilterOnLastItemTo = dateTo.AddDays(1).AddMilliseconds(-1);
            }

            // Retrieving data from BusinessServices
            IForumThreadService srv = ServiceFactory.GetForumThreadService();
            ForumThreadContainer allData = srv.ForumThreadSelectFiltered(filter);
            DataTable dt = allData.AllAsDatatable;
            dt.DefaultView.Sort = sSortColumn;
            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 (ID.Value.Equals(dr["ID"]))
            {
              nSelectedRow = i;
              break;
            }
            bm.Position += 1;
              }
            }

            // Makes the row selected
            if (nSelectedRow <= ((DataTable) dtgMain.DataSource).DefaultView.Count && nSelectedRow > -1)
            {
              dtgMain.Select(nSelectedRow);
              dtgMain.CurrentRowIndex = nSelectedRow;
            }
            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.
            bool bIsEmptyGrid = (((DataTable) dtgMain.DataSource).DefaultView.Count == 0);
            tbbInactivate.Enabled = ! bIsEmptyGrid;
            tbbModify.Enabled = ! bIsEmptyGrid;
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba lépett fel a lista frissítése során.", ex);
              }
        }
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Prepage Save action
        /// </summary>
        // -------------------------------------------------------------------------------------
        private void SaveData()
        {
            if (m_bNewItem)
              {
            CurrentID = new DBGuid(Guid.NewGuid());
              }

              IForumThreadService srv = ServiceFactory.GetForumThreadService();
              ForumThread fth = new ForumThread(CurrentID);

              // Get control values
              fth.Name = txtName.Text;
              fth.Description = txtDescription.Text;
              fth.IsActive = cbxActivate.Checked;
              fth.ForumGroupRef = new Guid(cmbForumGroup.SelectedValue.ToString());

              // Save values
              if (m_bNewItem)
            srv.ForumThreadInsert(fth);
              else
            srv.ForumThreadUpdate(fth);
        }