/// <summary>
    /// Returns main search columns to filter.
    /// </summary>
    private string GetSearchColumns()
    {
        var ti = iObjectType.TypeInfo;

        if ((ti.DisplayNameColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN))
        {
            DisplayNameSelectedAsSearchColumn = true;

            // Get column for display name
            return(ti.DisplayNameColumn);
        }

        if ((ti.CodeNameColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN))
        {
            // Get column for code name
            return(ti.CodeNameColumn);
        }

        if (!String.IsNullOrEmpty(displayNameFormat))
        {
            // Get columns from display name format if empty don't filter anything
            return(MacroProcessor.GetMacros(displayNameFormat));
        }

        return(String.Empty);
    }
Exemple #2
0
    private MacroResolver GetNodeMacroResolver(int NodeID, string ClassName)
    {
        string Culture = URLHelper.GetQueryValue(Request.RawUrl, "culture");

        return(CacheHelper.Cache <MacroResolver>(cs =>
        {
            MacroResolver resolver = MacroResolver.GetInstance();

            List <string> Columns = new List <string>();

            if (!string.IsNullOrWhiteSpace(ToolTipFormat))
            {
                Columns.AddRange(DataHelper.GetNotEmpty(MacroProcessor.GetMacros(ToolTipFormat, true), "NodeName").Split(';'));
            }
            if (!string.IsNullOrWhiteSpace(DisplayNameFormat))
            {
                Columns.AddRange(DataHelper.GetNotEmpty(MacroProcessor.GetMacros(DisplayNameFormat, true), "NodeName").Split(';'));
            }
            // Get data for this node and render it out
            DataSet FullData = new DocumentQuery(ClassName)
                               .WhereEquals("NodeID", NodeID)
                               .Columns(Columns)
                               .Culture(Culture)
                               .CombineWithDefaultCulture(true).Result;

            foreach (DataColumn item in FullData.Tables[0].Columns)
            {
                resolver.SetNamedSourceData(item.ColumnName, FullData.Tables[0].Rows[0][item.ColumnName]);
            }

            if (cs.Cached)
            {
                cs.CacheDependency = CacheHelper.GetCacheDependency("nodeid|" + NodeID);
            }
            return resolver;
        }, new CacheSettings(CacheHelper.CacheMinutes(SiteContext.CurrentSiteName), "RelationshipTree_GetNodeMacroResolver", NodeID, Culture, ToolTipFormat, DisplayNameFormat)));
    }
Exemple #3
0
    /// <summary>
    /// Returns dataset for specified GeneralizedInfo.
    /// </summary>
    private DataSet GetData(string returnColumn, int offset, int maxRecords, ref int totalRecords, bool selection)
    {
        // If object type is set
        if (iObjectType != null)
        {
            // Init columns
            string  columns = null;
            DataSet ds      = null;

            if (!selection)
            {
                if (displayNameFormat == UniSelector.USER_DISPLAY_FORMAT)
                {
                    // Ensure columns which are needed for USER_DISPLAY_FORMAT
                    columns = "UserName, FullName";
                }
                else if (displayNameFormat != null)
                {
                    columns = DataHelper.GetNotEmpty(MacroProcessor.GetMacros(displayNameFormat), iObjectType.DisplayNameColumn).Replace(";", ", ");
                }
                else
                {
                    columns = iObjectType.DisplayNameColumn;
                }
            }

            // Add return column name
            columns = SqlHelper.MergeColumns(columns, returnColumn);

            // Add additional columns
            columns = SqlHelper.MergeColumns(columns, additionalColumns);

            // Get SiteID column if needed
            if (AddGlobalObjectSuffix && !string.IsNullOrEmpty(iObjectType.SiteIDColumn))
            {
                columns = SqlHelper.MergeColumns(columns, iObjectType.SiteIDColumn);
            }

            string where = SqlHelper.AddWhereCondition(whereCondition, FilterWhere);
            if (!String.IsNullOrEmpty(uniGrid.WhereClause))
            {
                where = SqlHelper.AddWhereCondition(where, uniGrid.WhereClause);
            }

            // Apply site restrictions
            if (!string.IsNullOrEmpty(siteWhereCondition))
            {
                where = SqlHelper.AddWhereCondition(where, siteWhereCondition);
            }

            string order = String.Empty;

            // Order by
            if (String.IsNullOrEmpty(orderBy))
            {
                order += iObjectType.DisplayNameColumn;
            }
            else
            {
                order += orderBy;
            }

            try
            {
                // Get the data query
                var q = iObjectType.GetDataQuery(
                    UseTypeCondition,
                    s => s
                    .Where(where)
                    .OrderBy(order)
                    .Columns(columns),
                    true
                    );

                q.IncludeBinaryData = false;
                q.Offset            = offset;
                q.MaxRecords        = maxRecords;

                // Get the data
                ds           = q.Result;
                totalRecords = q.TotalRecords;
            }
            catch (Exception ex)
            {
                EventLogProvider.LogException("UniSelector", "GETDATA", ex);

                uniGrid.ShowError(ex.Message);
            }

            return(ds);
        }
        else
        {
            totalRecords = 0;
            return(null);
        }
    }
    /// <summary>
    /// Returns dataset for specified GeneralizedInfo.
    /// </summary>
    private DataSet GetData(string returnColumn, int offset, int maxRecords, ref int totalRecords, bool selection)
    {
        // If object type is set
        if (iObjectType != null)
        {
            // Init columns
            string  columns = null;
            DataSet ds      = null;

            if (!selection)
            {
                if (displayNameFormat == UniSelector.USER_DISPLAY_FORMAT)
                {
                    // Ensure columns which are needed for USER_DISPLAY_FORMAT
                    columns = "UserName, FullName";
                }
                else if (displayNameFormat != null)
                {
                    columns = DataHelper.GetNotEmpty(MacroProcessor.GetMacros(displayNameFormat, true), iObjectType.DisplayNameColumn).Replace(";", ", ");
                }
                else
                {
                    columns = iObjectType.DisplayNameColumn;
                }
            }

            // Add return column name
            columns = SqlHelper.MergeColumns(columns, returnColumn);

            // Add additional columns
            columns = SqlHelper.MergeColumns(columns, additionalColumns);

            // Ensure display name column for query within localized filtering (SelectAll/DeselectAll calls the query with ID column only)
            if (UseLocalizedFiltering)
            {
                columns = SqlHelper.MergeColumns(columns, iObjectType.TypeInfo.DisplayNameColumn);
            }

            var ti = iObjectType.TypeInfo;

            // Get SiteID column if needed
            if (AddGlobalObjectSuffix && HasSiteIdColumn(ti))
            {
                columns = SqlHelper.MergeColumns(columns, ti.SiteIDColumn);
            }

            string where = SqlHelper.AddWhereCondition(whereCondition, FilterWhere);
            if (!String.IsNullOrEmpty(uniGrid.WhereClause))
            {
                where = SqlHelper.AddWhereCondition(where, uniGrid.WhereClause);
            }

            // Apply site restrictions
            if (!string.IsNullOrEmpty(siteWhereCondition))
            {
                where = SqlHelper.AddWhereCondition(where, siteWhereCondition);
            }

            string order = String.Empty;

            // Order by
            if (String.IsNullOrEmpty(orderBy))
            {
                order += iObjectType.DisplayNameColumn;
            }
            else
            {
                order += orderBy;
            }

            try
            {
                // Get the data query
                var q = iObjectType.GetDataQuery(
                    UseTypeCondition,
                    s => s
                    .Where(where)
                    .OrderBy(order)
                    .Columns(columns),
                    true
                    );

                q.IncludeBinaryData = false;

                if (UseLocalizedFiltering)
                {
                    if (!DataHelper.DataSourceIsEmpty(q.Result))
                    {
                        var displayNameColumn = iObjectType.DisplayNameColumn;

                        ds = q.Result;
                        LocalizeAndFilterDataSet(ds, displayNameColumn, TrimmedSearchText);
                        SortDataSetTable(ds, displayNameColumn);

                        totalRecords = ds.Tables[0].Rows.Count;
                        return(ds);
                    }
                    else
                    {
                        totalRecords = 0;
                        return(null);
                    }
                }
                else
                {
                    q.Offset     = offset;
                    q.MaxRecords = maxRecords;

                    ds           = q.Result;
                    totalRecords = q.TotalRecords;
                }
            }
            catch (Exception ex)
            {
                EventLogProvider.LogException("UniSelector", "GETDATA", ex);

                uniGrid.ShowError(ex.Message);
            }

            return(ds);
        }
        else
        {
            totalRecords = 0;
            return(null);
        }
    }