Esempio n. 1
0
        /// <summary>
        /// Set a <see cref="ISearchCondition{T}"/> for DICOM string based (wildcard matching) value.
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="val"></param>
        private static void SetStringCondition(ISearchCondition <string> cond, string val)
        {
            if (val.Length == 0)
            {
                return;
            }

            if (val.Contains("*") || val.Contains("?"))
            {
                //TODO Remove when paging is implemented on queries
                int charCount = 0;
                foreach (char c in val)
                {
                    if (c != '*' && c != '?')
                    {
                        charCount++;
                    }
                }
                if (charCount < 4)
                {
                    throw new ArgumentException("Wildcard parameters require at least 4 characters.");
                }

                String value = val.Replace("%", "[%]").Replace("_", "[_]");
                value = value.Replace('*', '%');
                value = value.Replace('?', '_');
                cond.Like(value);
            }
            else
            {
                cond.EqualTo(val);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Set a <see cref="ISearchCondition{T}"/> for a DICOM range matching string value.
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="val"></param>
        public static void SetRangeCondition(ISearchCondition <string> cond, string val)
        {
            if (val.Length == 0)
            {
                return;
            }

            if (val.Contains("-"))
            {
                string[] vals = val.Split(new[] { '-' });
                if (val.IndexOf('-') == 0)
                {
                    cond.LessThanOrEqualTo(vals[1]);
                }
                else if (val.IndexOf('-') == val.Length - 1)
                {
                    cond.MoreThanOrEqualTo(vals[0]);
                }
                else
                {
                    cond.Between(vals[0], vals[1]);
                }
            }
            else
            {
                cond.EqualTo(val);
            }
        }
Esempio n. 3
0
		private static void ApplyCondition(ISearchCondition<string> condition, string value, bool exactMatch)
		{
			if(exactMatch)
				condition.EqualTo(value);
			else
				condition.StartsWith(value);
		}
Esempio n. 4
0
        /// <summary>
        /// Set a <see cref="ISearchCondition{T}"/> for an array of matching string values.
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="vals"></param>
        public static void SetStringArrayCondition(ISearchCondition<string> cond, string[] vals)
        {
            if (vals == null || vals.Length == 0)
                return;

            if (vals.Length == 1)
                cond.EqualTo(vals[0]);
            else
                cond.In(vals);
        }
Esempio n. 5
0
 private static void ApplyCondition(ISearchCondition <string> condition, string value, bool exactMatch)
 {
     if (exactMatch)
     {
         condition.EqualTo(value);
     }
     else
     {
         condition.StartsWith(value);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Set a <see cref="ISearchCondition{T}"/> for DICOM string based (wildcard matching) value.
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="val"></param>
        public static void SetStringCondition(ISearchCondition<string> cond, string val)
        {
            if (val.Length == 0 || SearchValueOnlyWildcard(val, false))
                return;

            if (val.Contains("*") || val.Contains("?"))
            {
                String value = val.Replace("%", "[%]").Replace("_", "[_]");
                value = value.Replace('*', '%');
                value = value.Replace('?', '_');
                cond.Like(value);
            }
            else
                cond.EqualTo(val);
        }
Esempio n. 7
0
        /// <summary>
        /// Set a <see cref="ISearchCondition{T}"/> for an array of matching string values.
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="vals"></param>
        public static void SetStringArrayCondition(ISearchCondition <string> cond, string[] vals)
        {
            if (vals == null || vals.Length == 0)
            {
                return;
            }

            if (vals.Length == 1)
            {
                cond.EqualTo(vals[0]);
            }
            else
            {
                cond.In(vals);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Set a <see cref="ISearchCondition{T}"/> for a <see cref="ServerEntityKey"/> reference.
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="vals"></param>
        public static void SetKeyCondition(ISearchCondition <ServerEntityKey> cond, ServerEntityKey[] vals)
        {
            if (vals == null || vals.Length == 0)
            {
                return;
            }

            if (vals.Length == 1)
            {
                cond.EqualTo(vals[0]);
            }
            else
            {
                cond.In(vals);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Set a <see cref="ISearchCondition{T}"/> for a DICOM range matching string value.
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="val"></param>
        public static void SetRangeCondition(ISearchCondition<string> cond, string val)
        {
            if (val.Length == 0)
                return;

            if (val.Contains("-"))
            {
                string[] vals = val.Split(new[] { '-' });
                if (val.IndexOf('-') == 0)
                    cond.LessThanOrEqualTo(vals[1]);
                else if (val.IndexOf('-') == val.Length - 1)
                    cond.MoreThanOrEqualTo(vals[0]);
                else
                    cond.Between(vals[0], vals[1]);
            }
            else
                cond.EqualTo(val);
        }
Esempio n. 10
0
        /// <summary>
        /// Set a <see cref="ISearchCondition{T}"/> for DICOM string based (wildcard matching) value.
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="val"></param>
        private static void SetStringCondition(ISearchCondition <string> cond, string val)
        {
            if (val.Length == 0)
            {
                return;
            }

            if (val.Contains("*") || val.Contains("?"))
            {
                String value = val.Replace("%", "[%]").Replace("_", "[_]");
                value = value.Replace('*', '%');
                value = value.Replace('?', '_');
                cond.Like(value);
            }
            else
            {
                cond.EqualTo(val);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Set a xPath based <see cref="ISearchCondition{T}"/> for an <see cref="XmlDocument"/> column.
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="xPath"></param>
        /// <param name="match"></param>
        public static void SetXmlStringCondition(ISearchCondition <XmlDocument> cond, string xPath, string match)
        {
            var doc = new XmlDocument();

            var xPathElem = doc.CreateElement("Select");

            doc.AppendChild(xPathElem);

            var equalElem = doc.CreateElement("XPath");

            xPathElem.AppendChild(equalElem);

            var attribElem = doc.CreateAttribute("path");

            attribElem.Value = xPath;
            xPathElem.Attributes.Append(attribElem);

            if (match.Contains("*") || match.Contains("?"))
            {
                var value = match.Replace("%", "[%]").Replace("_", "[_]");
                value = value.Replace('*', '%');
                value = value.Replace('?', '_');

                attribElem       = doc.CreateAttribute("value");
                attribElem.Value = value;
                xPathElem.Attributes.Append(attribElem);

                cond.Like(doc);
            }
            else
            {
                attribElem       = doc.CreateAttribute("value");
                attribElem.Value = match;
                xPathElem.Attributes.Append(attribElem);

                cond.EqualTo(doc);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Set a <see cref="ISearchCondition{T}"/> for DICOM string based (wildcard matching) value.
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="val"></param>
        private static void SetStringCondition(ISearchCondition<string> cond, string val)
        {
            if (val.Length == 0)
                return;

            if (val.Contains("*") || val.Contains("?"))
            {
                //TODO Remove when paging is implemented on queries
                int charCount = 0;
                foreach (char c in val)
                    if (c != '*' && c != '?')
                        charCount++;
                if (charCount < 4)
                    throw new ArgumentException("Wildcard parameters require at least 4 characters.");

                String value = val.Replace("%", "[%]").Replace("_", "[_]");
                value = value.Replace('*', '%');
                value = value.Replace('?', '_');
                cond.Like(value);
            }
            else
                cond.EqualTo(val);
        }
Esempio n. 13
0
        /// <summary>
        /// Set a xPath based <see cref="ISearchCondition{T}"/> for an <see cref="XmlDocument"/> column.
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="xPath"></param>
        /// <param name="match"></param>
        public static void SetXmlStringCondition(ISearchCondition<XmlDocument> cond, string xPath, string match)
        {
            var doc = new XmlDocument();

            var xPathElem = doc.CreateElement("Select");
            doc.AppendChild(xPathElem);

            var equalElem = doc.CreateElement("XPath");
            xPathElem.AppendChild(equalElem);

            var attribElem = doc.CreateAttribute("path");
            attribElem.Value = xPath;
            xPathElem.Attributes.Append(attribElem);

            if (match.Contains("*") || match.Contains("?"))
            {
                var value = match.Replace("%", "[%]").Replace("_", "[_]");
                value = value.Replace('*', '%');
                value = value.Replace('?', '_');

                attribElem = doc.CreateAttribute("value");
                attribElem.Value = value;
                xPathElem.Attributes.Append(attribElem);

                cond.Like(doc);
            }
            else
            {
                attribElem = doc.CreateAttribute("value");
                attribElem.Value = match;
                xPathElem.Attributes.Append(attribElem);

                cond.EqualTo(doc);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Set a <see cref="ISearchCondition{T}"/> for a <see cref="ServerEntityKey"/> reference.
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="vals"></param>
        public static void SetKeyCondition(ISearchCondition<ServerEntityKey> cond, ServerEntityKey[] vals)
        {
            if (vals == null || vals.Length == 0)
                return;

            if (vals.Length == 1)
                cond.EqualTo(vals[0]);
            else
                cond.In(vals);
        }