コード例 #1
0
        public FinancialTransactionsExport Export(
            int page      = 1,
            int pageSize  = 1000,
            string sortBy = null,
            System.Web.UI.WebControls.SortDirection sortDirection = System.Web.UI.WebControls.SortDirection.Ascending,
            int?dataViewId         = null,
            DateTime?modifiedSince = null,
            DateTime?startDateTime = null,
            DateTime?endDateTime   = null,
            string attributeKeys   = null,
            AttributeReturnType attributeReturnType = AttributeReturnType.Raw
            )
        {
            // limit to 'API Max Items Per Page' global attribute
            int maxPageSize    = GlobalAttributesCache.Get().GetValue("core_ExportAPIsMaxItemsPerPage").AsIntegerOrNull() ?? 1000;
            var actualPageSize = Math.Min(pageSize, maxPageSize);

            FinancialTransactionExportOptions exportOptions = new FinancialTransactionExportOptions
            {
                SortBy              = sortBy,
                SortDirection       = sortDirection,
                DataViewId          = dataViewId,
                ModifiedSince       = modifiedSince,
                AttributeList       = AttributesExport.GetAttributesFromAttributeKeys <FinancialTransaction>(attributeKeys),
                AttributeReturnType = attributeReturnType,
                StartDateTime       = startDateTime,
                EndDateTime         = endDateTime
            };

            var rockContext = new RockContext();
            var financialTransactionService = new FinancialTransactionService(rockContext);

            return(financialTransactionService.GetFinancialTransactionExport(page, actualPageSize, exportOptions));
        }
コード例 #2
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------
        public List <MGUser> GetUsers(List <string> fieldsToSearch, string valueToSearch, string sortColumnName, System.Web.UI.WebControls.SortDirection sortDirection)
        {
            List <MGUser> result = new List <MGUser>();

            UserOperations userOps = null;

            bool isLockAcquired = Monitor.TryEnter(USER_ADMIN_LOCK_OBJ, USER_ADMIN_LOCK_TIMEOUT);

            if (isLockAcquired)
            {
                try {
                    userOps = new UserOperations(MGLApplicationSecurityInterface.Instance().DatabaseConfig);

                    result = userOps.GetAllUsers(fieldsToSearch, valueToSearch, sortColumnName, sortDirection);
                } catch (Exception ex) {
                    Logger.LogError(8, "Error in UserAdministration.GetUsers (Without PreviousSortColumnNames)." + ex.Message);
                } finally {
                    Monitor.Exit(USER_ADMIN_LOCK_OBJ);
                    if (userOps != null)
                    {
                        userOps.Finish();
                    }
                }
            }
            else
            {
                Logger.LogError(8, "Failed to get exclusive lock in GetUsers to read the Users table!");
                return(result);
            }

            return(result);
        }
コード例 #3
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------
        public List <MGUser> GetUsers(string filterByType, string filterByValue, string sortColumn, List <string> PreviousSortColumnNames, System.Web.UI.WebControls.SortDirection sortDirection)
        {
            List <MGUser> result = new List <MGUser>();

            UserOperations userOps        = null;
            bool           isLockAcquired = Monitor.TryEnter(USER_ADMIN_LOCK_OBJ, USER_ADMIN_LOCK_TIMEOUT);

            if (isLockAcquired)
            {
                try {
                    userOps = new UserOperations(MGLApplicationSecurityInterface.Instance().DatabaseConfig);

                    result = userOps.GetAllUsers(filterByType, filterByValue, sortColumn, PreviousSortColumnNames, sortDirection);
                } catch (Exception ex) {
                    Logger.LogError(8, "Error in UserAdministration.GetUsers." + ex.Message);
                } finally {
                    Monitor.Exit(USER_ADMIN_LOCK_OBJ);
                    if (userOps != null)
                    {
                        userOps.Finish();
                    }
                }
            }

            return(result);
        }
コード例 #4
0
 public GridViewSortEventArgs(string sortExpression, System.Web.UI.WebControls.SortDirection sortDirection)
 {
     this._sortExpression = sortExpression;
     this._sortDirection  = sortDirection;
 }
コード例 #5
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------
        private string GetSQLForGettingAllUsers(List <string> searchFields, string searchString, string sortColumnName, System.Web.UI.WebControls.SortDirection sortDirection)
        {
            string whereClause = string.Empty;
            string descOrAsc   = "";

            if (sortDirection == System.Web.UI.WebControls.SortDirection.Descending)
            {
                descOrAsc = " DESC ";
            }

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT " + userFields + " FROM " + tnUsers + " ");


            //If the search field list is not null then create a Where Clause
            if (searchFields != null && searchFields.Count > 0 && !NullOrEmpty(searchString))
            {
                whereClause = " WHERE ";
                int totoalMembers = searchFields.Count;
                int i             = 1;
                foreach (string fieldName in searchFields)
                {
                    whereClause += fieldName + " LIKE '%" + searchString + "%'";
                    if (totoalMembers != i)
                    {
                        whereClause += " OR ";
                    }
                    i++;
                    //WHERE UserName like '%hartley%' or JobTitle like '%hartley%' or Email like '%hartley%'
                }
            }

            if (whereClause != null && whereClause != string.Empty)
            {
                sql.Append(whereClause);
            }
            sql.Append("ORDER BY ");
            if (NullOrEmpty(sortColumnName))
            {
                sql.Append(" ID ");
            }
            else
            {
                sql.Append(sortColumnName);
            }
            sql.Append(descOrAsc);
            sql.Append(";");

            return(sql.ToString());
        }
コード例 #6
0
        ////-------------------------------------------------------------------------------------------------------------------------------------------------------------
        ///// <summary>
        ///// Gets a list of MGUsers from a legacy administrator table.
        ///// The last column specified should be the password field.
        ///// </summary>
        ///// <param name="tablename">The name of the legacy administrator table.</param>
        ///// <param name="tableColumnCSV">A comma-seperated list of user columns to select to populate the MGUser object.</param>
        ///// <returns>All users in the system as list of MGUser objects.</returns>
        //public List<MGUser> GetUsersFromLegacyTable(string tablename, string tableColumnCSV) {
        //    List<MGUser> users = new List<MGUser>();
        //    string sqlQuery = "SELECT " + tableColumnCSV + " FROM " + tablename + " ORDER BY ID;";

        //    List<string[]> data = dbInfo.GetDataList(sqlQuery);

        //    if (data != null) {
        //        MGUser user = null;
        //        foreach (string[] row in data) {
        //            user = BuildUserInfo(row);
        //            user.Password = row[row.Length - 1];
        //            users.Add(user);
        //        }
        //    }

        //    return users;

        //}


        //-------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// GetAllUsers with filter/sort parameters
        ///
        /// Default sort is by user ID
        /// </summary>
        /// <param name="filterByType"></param>
        /// <param name="filterByValue">If this is a string it will need to be enclosed in single quotes ' ' </param>
        /// <param name="sortColumnName"></param>
        /// <param name="sortDirection"></param>
        /// <returns></returns>
        public List <MGUser> GetAllUsers(string filterByType, string filterByValue, string sortColumnName, List <string> PreviousSortColumnNames, System.Web.UI.WebControls.SortDirection sortDirection)
        {
            string sqlQuery  = "";
            string descOrAsc = "";

            string otherSortColumns = "";

            if (PreviousSortColumnNames != null && PreviousSortColumnNames.Count > 0)
            {
                foreach (string colName in PreviousSortColumnNames)
                {
                    if (colName != null)
                    {
                        otherSortColumns += " , " + colName;
                    }
                }
            }

            if (sortDirection == System.Web.UI.WebControls.SortDirection.Descending)
            {
                descOrAsc = " DESC ";
            }

            List <MGUser> users = new List <MGUser>();

            if (NullOrEmpty(filterByType) && NullOrEmpty(sortColumnName))
            {
                sqlQuery = "SELECT " + userFields + " FROM " + tnUsers + " ORDER BY ID " + descOrAsc + otherSortColumns + ";";
            }
            else if (!NullOrEmpty(filterByType) && NullOrEmpty(sortColumnName))
            {
                sqlQuery = "SELECT " + userFields + " FROM " + tnUsers + " WHERE " + filterByType + "=" + filterByValue + "ORDER BY ID" + descOrAsc + otherSortColumns + ";";
            }
            else if (!NullOrEmpty(sortColumnName) && NullOrEmpty(filterByType))
            {
                sqlQuery = "SELECT " + userFields + " FROM " + tnUsers + " ORDER BY " + sortColumnName + descOrAsc + otherSortColumns + ";";
            }
            else if (!NullOrEmpty(filterByType) && !NullOrEmpty(sortColumnName))
            {
                sqlQuery = "SELECT " + userFields + " FROM " + tnUsers + " WHERE " + filterByType + "=" + filterByValue + " ORDER BY " + sortColumnName + descOrAsc + otherSortColumns + ";";
            }

            users = GetListOfUsers(sqlQuery);

            return(users);
        }
コード例 #7
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------
        public List <MGUser> GetAllUsers(List <string> fieldsToSearch, string valueToSearch, string sortColumnName, System.Web.UI.WebControls.SortDirection sortDirection)
        {
            string sqlQuery = "";

            sqlQuery = GetSQLForGettingAllUsers(fieldsToSearch, valueToSearch, sortColumnName, sortDirection);
            return(GetListOfUsers(sqlQuery));
        }
コード例 #8
0
 private bool LoadHiddenFieldState(string pageIndex, string sortDirection, string sortExpressionSerialized, string dataKeysSerialized)
 {
     bool flag = false;
     int num = int.Parse(pageIndex, CultureInfo.InvariantCulture);
     System.Web.UI.WebControls.SortDirection direction = (System.Web.UI.WebControls.SortDirection) int.Parse(sortDirection, CultureInfo.InvariantCulture);
     string str = string.Empty;
     object state = null;
     if (!string.IsNullOrEmpty(sortExpressionSerialized) || !string.IsNullOrEmpty(dataKeysSerialized))
     {
         if (this.Page == null)
         {
             throw new InvalidOperationException();
         }
         IStateFormatter stateFormatter = this.StateFormatter;
         if (!string.IsNullOrEmpty(sortExpressionSerialized))
         {
             str = (string) stateFormatter.Deserialize(sortExpressionSerialized);
         }
         if (!string.IsNullOrEmpty(dataKeysSerialized))
         {
             state = stateFormatter.Deserialize(dataKeysSerialized);
         }
     }
     if (((this._pageIndex != num) || (this._sortDirection != direction)) || (this._sortExpression != str))
     {
         flag = true;
         this._pageIndex = num;
         this._sortExpression = str;
         this._sortDirection = direction;
         if (state == null)
         {
             return flag;
         }
         if (this._dataKeysArrayList != null)
         {
             this._dataKeysArrayList.Clear();
         }
         this.LoadDataKeysState(state);
     }
     return flag;
 }
コード例 #9
0
 protected internal override void LoadControlState(object savedState)
 {
     this._editIndex = -1;
     this._pageIndex = 0;
     this._selectedIndex = -1;
     this._sortExpression = string.Empty;
     this._sortDirection = System.Web.UI.WebControls.SortDirection.Ascending;
     this._dataKeyNames = new string[0];
     this._pageCount = -1;
     object[] objArray = savedState as object[];
     if (objArray != null)
     {
         base.LoadControlState(objArray[0]);
         if (objArray[1] != null)
         {
             this._editIndex = (int) objArray[1];
         }
         if (objArray[2] != null)
         {
             this._pageIndex = (int) objArray[2];
         }
         if (objArray[3] != null)
         {
             this._selectedIndex = (int) objArray[3];
         }
         if (objArray[4] != null)
         {
             this._sortExpression = (string) objArray[4];
         }
         if (objArray[5] != null)
         {
             this._sortDirection = (System.Web.UI.WebControls.SortDirection) objArray[5];
         }
         if (objArray[6] != null)
         {
             this._dataKeyNames = (string[]) objArray[6];
         }
         if (objArray[7] != null)
         {
             this.LoadDataKeysState(objArray[7]);
         }
         if (objArray[8] != null)
         {
             this._pageCount = (int) objArray[8];
         }
         if (((objArray[9] != null) && (this._dataKeyNames != null)) && (this._dataKeyNames.Length > 0))
         {
             this._persistedDataKey = new DataKey(new OrderedDictionary(this._dataKeyNames.Length), this._dataKeyNames);
             ((IStateManager) this._persistedDataKey).LoadViewState(objArray[9]);
         }
         if (objArray[10] != null)
         {
             this._clientIDRowSuffix = (string[]) objArray[10];
         }
         if (objArray[11] != null)
         {
             this.LoadClientIDRowSuffixDataKeysState(objArray[11]);
         }
     }
     else
     {
         base.LoadControlState(null);
     }
 }
コード例 #10
0
        public static IQueryable <T> IQueryableSort <T>(this IQueryable <T> source, string ordering, System.Web.UI.WebControls.SortDirection direction)
        {
            var type           = typeof(T);
            var property       = type.GetProperty(ordering);
            var parameter      = Expression.Parameter(type, "p");
            var propertyAccess = Expression.MakeMemberAccess(parameter, property);
            var orderByExp     = Expression.Lambda(propertyAccess, parameter);
            MethodCallExpression resultExp;

            if (direction == System.Web.UI.WebControls.SortDirection.Ascending)
            {
                resultExp = Expression.Call(typeof(Queryable), "OrderBy", new Type[] { type, property.PropertyType }, source.Expression, Expression.Quote(orderByExp));
            }
            else
            {
                resultExp = Expression.Call(typeof(Queryable), "OrderByDescending", new Type[] { type, property.PropertyType }, source.Expression, Expression.Quote(orderByExp));
            }

            return(source.Provider.CreateQuery <T>(resultExp));
        }
 public GridViewSortEventArgs(string sortExpression, System.Web.UI.WebControls.SortDirection sortDirection)
 {
     this._sortExpression = sortExpression;
     this._sortDirection = sortDirection;
 }