internal static string ProcessReportFilter(
            SPList list,
            SPWeb web,
            IReportID provider,
            ref ArrayList reportFilterIds,
            ref string reportFilterField)
        {
            var returnValue = string.Empty;

            if (provider != null)
            {
                var listId = Guid.Empty;
                var localReportFilterIds = reportFilterIds;

                SPSecurity.RunWithElevatedPrivileges(
                    delegate
                {
                    try
                    {
                        using (var sqlConnection = new SqlConnection(CoreFunctions.getConnectionString(web.Site.WebApplication.Id)))
                        {
                            sqlConnection.Open();

                            using (var sqlCommand = new SqlCommand(
                                       "SELECT VALUE,listid FROM PERSONALIZATIONS where userid=@userid and [key]=@key and FK=@FK",
                                       sqlConnection))
                            {
                                sqlCommand.Parameters.AddWithValue("@userid", web.CurrentUser.ID);
                                sqlCommand.Parameters.AddWithValue("@key", "ReportFilterWebPartSelections");
                                sqlCommand.Parameters.AddWithValue("@FK", provider.ReportID.Replace("g_", "").Replace("_", "-"));
                                sqlCommand.ExecuteNonQuery();
                                using (var dataReader = sqlCommand.ExecuteReader())
                                {
                                    if (dataReader.Read())
                                    {
                                        localReportFilterIds = new ArrayList(dataReader.GetString(0).Split('|')[0].Split(','));
                                        listId = dataReader.GetGuid(1);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError("Exception Suppressed {0}", ex);
                    }
                });

                reportFilterIds = localReportFilterIds;

                if (listId == list.ID)
                {
                    reportFilterField = "Title";

                    if (reportFilterIds.Count < MaxLookupFilter)
                    {
                        returnValue = "<In><FieldRef Name=\"Title\"/><Values>" + GetReportFilters(reportFilterIds) + "</Values></In>";
                    }
                }
                else if (listId != Guid.Empty)
                {
                    foreach (SPField oField in list.Fields)
                    {
                        if (oField.Type == SPFieldType.Lookup)
                        {
                            try
                            {
                                var oLookup = (SPFieldLookup)oField;
                                if (new Guid(oLookup.LookupList) == listId)
                                {
                                    reportFilterField = oLookup.InternalName;
                                    break;
                                }
                            }
                            catch (Exception ex)
                            {
                                Trace.TraceError("Exception Suppressed {0}", ex);
                            }
                        }
                    }

                    if (reportFilterIds.Count < MaxLookupFilter && reportFilterField != string.Empty)
                    {
                        returnValue = string.Format(
                            "<In><FieldRef Name=\"{0}\"/><Values>{1}</Values></In>",
                            reportFilterField,
                            GetReportFilters(reportFilterIds));
                    }
                }
            }

            return(returnValue);
        }
Exemplo n.º 2
0
 public void ReportIDConsumer(IReportID Provider)
 {
     _myProvider = Provider;
 }
Exemplo n.º 3
0
 public void ReportIdConsumer(IReportID provider)
 {
     _myProvider = provider;
 }