public void LoadByOrganizationID(int organizationId, NameValueCollection filters, int?PageNumber = null, int?PageSize = null)
        {
            //Get the column names
            LoadColumns("DeletedTickets");

            string orderBy = "ORDER BY DateDeleted DESC";
            string sql     = string.Empty;

            using (SqlCommand command = new SqlCommand())
            {
                SqlParameterCollection filterParameters = command.Parameters;
                string whereClause = DataUtils.BuildWhereClausesFromFilters(this.LoginUser, this, organizationId, filters, ReferenceType.DeletedTickets, "ID", null, ref filterParameters);
                sql = @"
                SELECT 
                    *
                FROM
                    DeletedTickets
                WHERE
                    OrganizationID = @organizationId " + whereClause + " " + orderBy;

                sql = DataUtils.AddPaging(sql, PageSize, PageNumber, command);

                command.CommandText = sql;
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@organizationId", organizationId);

                Fill(command);
            }
        }
예제 #2
0
        public void LoadByParentOrganizationID(int organizationParentId, NameValueCollection filters, int?pageNumber = null, int?pageSize = null, string orderBy = "LastName, FirstName", int?limitNumber = null, bool isCustomer = false, bool useMaxDop = false)
        {
            //Get the column names, this row will be deleted before getting the actual data
            this.LoadOneByParentOrganizationID(organizationParentId);

            using (SqlCommand command = new SqlCommand())
            {
                string limit = string.Empty;

                if (limitNumber != null)
                {
                    limit = "TOP " + limitNumber.ToString();
                }

                string sql = BuildLoadByParentOrganizationIdSql(limit, organizationParentId, orderBy, filters, command.Parameters, isCustomer, useMaxDop);
                sql = InjectCustomFields(sql, "UserID", ReferenceType.Contacts);
                sql = DataUtils.AddPaging(sql, pageSize, pageNumber, command);
                command.CommandType = CommandType.Text;
                command.CommandText = sql;
                command.Parameters.AddWithValue("@OrganizationParentId", organizationParentId);

                //Hack: ContactsView has the column Email size of nvarchar(1024). We are applying this here specifically for this column, the better way should be to do it for all everytime but that might be a massive change to the base code for the data processing.
                bool hasEmailParameter = (filters.AllKeys.Where(p => p.ToLower() == "email").Any() || filters.AllKeys.Where(p => p.ToLower().Contains("email[")).Any()) && command.Parameters.Contains("@email");

                if (hasEmailParameter)
                {
                    command.Parameters["@email"].Size = 1024;
                }

                this.DeleteAll();

                Fill(command);
            }
        }
        public void LoadByParentID(int parentID, bool includeCustomFields, NameValueCollection filters, int?pageNumber = null, int?pageSize = null, string orderBy = "Name")
        {
            this.LoadOneByParentID(parentID);

            if (this.Count > 0)
            {
                using (SqlCommand command = new SqlCommand())
                {
                    string sql = BuildLoadByParentIDSql(string.Empty, parentID, orderBy, filters, command.Parameters);
                    sql = DataUtils.AddPaging(sql, pageSize, pageNumber, command);

                    if (includeCustomFields)
                    {
                        sql = InjectCustomFields(sql, "OrganizationsView.OrganizationID", ReferenceType.Organizations);
                    }

                    command.CommandText = sql;
                    command.CommandType = CommandType.Text;
                    this.DeleteAll();
                    Fill(command);
                }
            }
        }