Beispiel #1
0
        /// <summary>
        /// If we really don't know anything about the module (which is likely with custom modules)
        /// the best we can do is see whether any of its text fields matches the search text.
        /// </summary>
        /// <param name="moduleName">The name of the module to search.</param>
        /// <param name="escapedSearchText">The text to search for, escaped for MySQL.</param>
        /// <returns>A query string.</returns>
        private static string ConstructQueryTextForUnknownModule(string moduleName, string escapedSearchText)
        {
            StringBuilder queryBuilder = new StringBuilder();

            if (RestAPIWrapper.GetActivitiesLinks(moduleName, Objective.Email).Count() > 0)
            {
                string tableName = moduleName.ToLower();

                foreach (string fieldName in RestAPIWrapper.GetCharacterFields(moduleName))
                {
                    switch (fieldName)
                    {
                    case "name":
                    case "first_name":
                    case "last_name":
                        queryBuilder.Append($"{tableName}.{fieldName} LIKE '%{escapedSearchText}%' OR ");
                        break;
                    }
                }

                queryBuilder.Append($"{tableName}.id in (select eabr.bean_id from email_addr_bean_rel eabr ")
                .Append("INNER JOIN email_addresses ea on eabr.email_address_id = ea.id ")
                .Append($"where eabr.bean_module = '{moduleName}' ")
                .Append($" and ea.email_address LIKE '{escapedSearchText}')");
            }

            return(queryBuilder.ToString());
        }