internal static AnalyticsReportFilter GetStringAnalyticsReportFilter(string Name, String searchPhrase, int searchOperator, bool specifyAttributes, bool specifyDatatype, bool specifyOperator)
        {
            //Assigning the filter as defined on the RightNow Analytics Report
            AnalyticsReportFilter filter = new AnalyticsReportFilter();

            if (specifyAttributes)
            {
                AnalyticsReportFilterAttributes attribute = new AnalyticsReportFilterAttributes();
                attribute.Editable = false;
                attribute.Required = false;
                filter.Attributes  = attribute;
            }

            if (specifyDatatype)
            {
                NamedID datatype = new NamedID();
                datatype.Name   = Name.GetType().ToString();
                filter.DataType = datatype;
            }

            filter.Name = Name;
            if (specifyOperator)
            {
                filter.Operator = new NamedID {
                    ID = new ID {
                        id = searchOperator, idSpecified = true
                    }
                }
            }
            ;
            filter.Values = new String[] { searchPhrase };

            return(filter);
        }
        internal static AnalyticsReportFilter GetDateTimeRangeAnalyticsReportFilter(string Name, DateTime fromDateTime, DateTime toDateTime, bool specifyAttributes, bool specifyDatatype, bool specifyOperator, bool appendEndingZ)
        {
            //Assigning the filter as defined on the RightNow Analytics Report
            AnalyticsReportFilter filter = new AnalyticsReportFilter();

            if (specifyAttributes)
            {
                AnalyticsReportFilterAttributes attribute = new AnalyticsReportFilterAttributes();
                attribute.Editable = false;
                attribute.Required = false;
                filter.Attributes  = attribute;
            }

            if (specifyDatatype)
            {
                NamedID datatype = new NamedID();
                datatype.Name   = "Date Time";
                filter.DataType = datatype;
            }

            filter.Name = Name;
            if (fromDateTime > DateTime.MinValue && toDateTime > DateTime.MinValue)
            {
                if (specifyDatatype)
                {
                    filter.Operator = new NamedID {
                        ID = new ID {
                            id = ANALYTICS_FILTER_RANGE, idSpecified = true
                        }
                    }
                }
                ;
                if (appendEndingZ)
                {
                    filter.Values = new[] { fromDateTime.ToString("s") + "Z", toDateTime.ToString("s") + "Z" }
                }
                ;
                else
                {
                    filter.Values = new[] { fromDateTime.ToString("s"), toDateTime.ToString("s") }
                };
            }
            else
            {
                if (fromDateTime > DateTime.MinValue)
                {
                    if (specifyDatatype)
                    {
                        filter.Operator = new NamedID {
                            ID = new ID {
                                id = ANALYTICS_FILTER_GREATER_THAN_OR_EQUAL, idSpecified = true
                            }
                        }
                    }
                    ;
                    if (appendEndingZ)
                    {
                        filter.Values = new[] { fromDateTime.ToString("s") + "Z" }
                    }
                    ;
                    else
                    {
                        filter.Values = new[] { fromDateTime.ToString("s") }
                    };
                }
                else if (toDateTime > DateTime.MinValue)
                {
                    if (specifyDatatype)
                    {
                        filter.Operator = new NamedID {
                            ID = new ID {
                                id = ANALYTICS_FILTER_LESS_THAN_OR_EQUAL, idSpecified = true
                            }
                        }
                    }
                    ;
                    if (appendEndingZ)
                    {
                        filter.Values = new[] { toDateTime.ToString("s") + "Z" }
                    }
                    ;
                    else
                    {
                        filter.Values = new[] { toDateTime.ToString("s") }
                    };
                }
            }

            return(filter);
        }