Exemplo n.º 1
0
        protected void ShowGrid(DataGrid dataGrid,
                            int index, string sort, string order)
        {
            dataGrid.PageSize = Helpers.GetPageSize("PageSize.KeywordList");

              // Get query result from database
              Thesaurus filter = new Thesaurus("%" + txtKeyword1.Text + "%");

              IThesaurusService srv = ServiceFactory.GetThesaurusService();
              ThesaurusContainer selected = srv.ThesaurusSelectForFilter(filter);

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

              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();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fill datagrid with data
        /// </summary>
        private void FillDatagridThesaurus(DBString ThesaurusID)
        {
            try
              {
            string sSortColumn = "Keyword";
            int nSelectedRow = -1;

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

            if (m_allDataThes == null)
            {
              // Retrieving data from BusinessServices

              // Retrieving Thesaurus
              IThesaurusService srv = ServiceFactory.GetThesaurusService();
              Thesaurus filter = new Thesaurus(ThesaurusID);
              filter.FilterOnIsactive = DBInt.Null;
              m_allDataThes = srv.ThesaurusSelectFiltered(filter);

              // Retrieving ProgramKeyword
              IProgramService srvP = ServiceFactory.GetProgramService();
              DBGuid ProgramID = new DBGuid(new Guid(m_sCurrentID));
              ProgramKeywordContainer allDataPK = srvP.SelectChildrenByProgramOfKeyword(ProgramID);

              // Hide selected Thesaurus items
              for (int i = 0; i < allDataPK.All.Count; i++)
              {
            DBString KeywordRef = ((ProgramKeyword) allDataPK.All.Items[i]).KeywordRef;
            Thesaurus selected = (Thesaurus) m_allDataThes[KeywordRef.ToString()];
            if (selected != null)
            {
              m_allDataThes.Delete(selected);
            }
              }
            }
            // Fill Thesaurus grid
            DataTable dt = m_allDataThes.CurrentAsDatatable;
            dt.DefaultView.Sort = sSortColumn;
            dtgThesaurus.DataSource = dt;

            // Fill Thesaurus "detail" grid
            DataTable dtDetail = m_allDataThes.DeletedAsDatatable;
            dtDetail.DefaultView.Sort = sSortColumn;
            dtgThesaurusDetail.DataSource = dtDetail;

            // Locates the row specified by ID param
            if (!ThesaurusID.IsNull)
            {
              BindingManagerBase bm = dtgExpert.BindingContext[dtgThesaurus.DataSource, dtgThesaurus.DataMember];
              int nPositionStart = bm.Position;
              DataRow dr;
              for (int i = 0; i < bm.Count; i++)
              {
            dr = ((DataRowView) bm.Current).Row;
            if (ThesaurusID.Value.Equals(dr["Keyword"]))
            {
              nSelectedRow = i;
              break;
            }
            bm.Position += 1;
              }
              bm.Position = nPositionStart;
            }

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

            // Enabling or disabling the buttons according to record count.
            // And is because of previous disable state.
            bool bIsEmptyGrid = (((DataTable) dtgThesaurus.DataSource).DefaultView.Count == 0);
            btnAddThesaurus.Enabled = ! bIsEmptyGrid;
            btnDetailThesaurus.Enabled = ! bIsEmptyGrid;

            bIsEmptyGrid = (((DataTable) dtgThesaurusDetail.DataSource).DefaultView.Count == 0);
            btnRemoveThesaurus.Enabled = ! bIsEmptyGrid;
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba lépett fel a tezaurusz lista frissítése során.", ex);
              }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Fill datagrid with data
        /// </summary>
        private void FillDatagrid(DBString ID)
        {
            try
              {
            string sSortColumn = "Keyword";
            int nSelectedRow = -1;

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

            // Set filter
            Thesaurus filter = new Thesaurus(ID);
            if (txtKeyword.Text.Length > 0)
            {
              filter.FilterOnKeyword = txtKeyword.Text;
            }
            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;
            }

            // Retrieving data from BusinessServices
            IThesaurusService srv = ServiceFactory.GetThesaurusService();
            ThesaurusContainer allData = srv.ThesaurusSelectFiltered(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["Keyword"]))
            {
              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);
            tbbModify.Enabled = ! bIsEmptyGrid;
            tbbInactivate.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);
              }
        }
Exemplo n.º 4
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public Thesaurus(Thesaurus origInstance)
     : base(origInstance)
 {
 }
Exemplo n.º 5
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="KeywordVal">Value of 'cKeyword' field</param>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public Thesaurus(DBString KeywordVal,
              Thesaurus origInstance)
     : base(KeywordVal, origInstance)
 {
 }
Exemplo n.º 6
0
 public virtual void ThesaurusUpdate(Thesaurus entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       int count;
       m_DataContext.ndihdThesaurusUpdate(entity.Keyword,
                                      entity.IsActive,
                                      entity.Description, 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;
       }
 }
Exemplo n.º 7
0
 public virtual void ThesaurusInsert(Thesaurus entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdThesaurusInsert(entity.Keyword,
                                      entity.IsActive,
                                      entity.Description);
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
Exemplo n.º 8
0
 public virtual Thesaurus ThesaurusSelect(DBString KeywordVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     Thesaurus result = null;
     DataSet entitySet = m_DataContext.ndihdThesaurusSelect(KeywordVal);
     if (entitySet.Tables[0].Rows.Count != 0)
     {
       result = new Thesaurus(entitySet);
     }
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
Exemplo n.º 9
0
        public void ThesaurusActivate(Thesaurus entity)
        {
            // Check permission: Administrator
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            if (entity.Keyword.Length == 0)
              throw new ArgumentNullException("Thesaurus.Keyword", "A kulcsszó nincs megadva.");

            // Logical checks
            Thesaurus selected = base.ThesaurusSelect(entity.Keyword);
            if (selected == null)
              throw new ApplicationException("Ezzel a kulcsszóval nem létezik tezaurusz cikk.");

            // Save data
            selected.IsActive = entity.IsActive;
            base.ThesaurusUpdate(selected);

            BusinessAuditEvent.Success(
              new EventParameter("Keyword", entity.Keyword)
              );
            TraceCallReturnEvent.Raise();
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("Keyword", entity.Keyword)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Exemplo n.º 10
0
        public new void ThesaurusUpdate(Thesaurus entity)
        {
            // Check permission: Admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Logical checks
            Thesaurus selected = base.ThesaurusSelect(entity.Keyword);
            if (selected == null)
              throw new ApplicationException("Ezzel a kulcsszóval nem létezik tezaurusz.");

            // Logical checks relations
            int numberOfParentRelations = 0;
            int numberOfSeeRelations = 0;
            foreach (ThesaurusRelation relation in entity.Relations.Current)
            {
              DBString RelationType = relation.RelationType;
              DBString RelatedWord = relation.RelatedWord;
              // Szinoníma (Több db szó lehet, de nem lehet létezõ vezérszó)
              if (RelationType.Equals(ThesaurusRelationType.Synonym))
              {
            Thesaurus thes = ThesaurusSelect(RelatedWord);
            if (thes != null)
            {
              throw new ApplicationException("A szinonima nem lehet már létezõ vezérszó.");
            }
              }

              // Fölérendelt kapcsolat (1 db már létezõ vezérszó lehet)
              if (RelationType.Equals(ThesaurusRelationType.Parent))
              {
            numberOfParentRelations += 1;
            if (numberOfParentRelations > 1)
            {
              throw new ApplicationException("Csak egy darab fölérendelt kulcsszó adható meg.");
            }
            Thesaurus thes = ThesaurusSelect(RelatedWord);
            if (thes == null)
            {
              throw new ApplicationException("A fölérendelt kulcsszó nem vezérszó. Csak már létezõ vezérszó adható meg.");
            }
              }

              // Helyettesítõ kapcsolat (1 db már létezõ vezérszó lehet)
              if (RelationType.Equals(ThesaurusRelationType.See))
              {
            numberOfSeeRelations += 1;
            if (numberOfSeeRelations > 1)
            {
              throw new ApplicationException("Csak egy darab helyettesítõ kulcsszó adható meg.");
            }
            Thesaurus thes = ThesaurusSelect(RelatedWord);
            if (thes == null)
            {
              throw new ApplicationException(
                "A helyettesítõ kulcsszó nem vezérszó. Csak már létezõ vezérszó adható meg.");
            }
              }

              // Lásd még kapcsolatok (Több db már létezõ vezérszó lehet)
              if (RelationType.Equals(ThesaurusRelationType.Also))
              {
            Thesaurus thes = ThesaurusSelect(RelatedWord);
            if (thes == null)
            {
              throw new ApplicationException(
                "A kapcsolódó lásd még kapcsolat nem vezérszó. Csak már létezõ vezérszó adható meg.");
            }
              }
            }

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

            ThesaurusRelationService srv = new ThesaurusRelationService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              // ThesaurusRelations - delete and insert
              m_DataContext.ndihdKeywordOfRelationDeleteBy(entity.Keyword);
              foreach (ThesaurusRelation rel in entity.Relations.Current)
              {
            srv.ThesaurusRelationInsert(rel);
              }

              // Thesaurus
              base.ThesaurusUpdate(selected);

              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter("Keyword", entity.Keyword)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("Keyword", entity.Keyword)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Exemplo n.º 11
0
        public ThesaurusContainer ThesaurusSelectForFilter(Thesaurus filter)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            string filterOnKeyword = filter.Keyword;
            if (filterOnKeyword.Length == 0)
            {
              filterOnKeyword = "%"; // return all
            }
            else
            {
              filterOnKeyword = filterOnKeyword.Replace("%", "%");
              filterOnKeyword = filterOnKeyword.Replace("_", "\\_");
              filterOnKeyword = filterOnKeyword.Replace("*", "%");
              filterOnKeyword = filterOnKeyword.Replace("?", "_");
            }

            ThesaurusContainer result;
            DataSet entitySet = m_DataContext.ndihdThesaurusSelectForFilter(
              filterOnKeyword);
            result = new ThesaurusContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Exemplo n.º 12
0
        public ThesaurusContainer ThesaurusSelectFiltered(Thesaurus filter)
        {
            // Check permission: Administrator
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            ThesaurusContainer result;
            DataSet entitySet = m_DataContext.ndihdThesaurusSelectFiltered(
              filter.FilterOnKeyword,
              filter.FilterOnIsactive);
            result = new ThesaurusContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Exemplo n.º 13
0
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Prepage Save action
        /// </summary>
        // -------------------------------------------------------------------------------------
        private void SaveData()
        {
            IThesaurusService thesSrv = ServiceFactory.GetThesaurusService();
              Thesaurus thes = new Thesaurus(txtKeyword.Text.Trim());

              // Get control values
              thes.Description = txtDescription.Text;
              thes.IsActive = cbxActivate.Checked;
              thes.Relations = m_data;

              // Save data
              if (m_bNewItem)
            thesSrv.ThesaurusInsert(thes);
              else
            thesSrv.ThesaurusUpdate(thes);
        }