示例#1
0
        /// <summary>
        /// Парсит входящую строку query и разбивает на поля имя,отч,фам,др
        /// понимает 3 символа, фио01012000, фам им отч
        /// предварительно преобразовывает qwerty в йцукен
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        private SearchTemplate ParseFioQuery(string query)
        {
            query = LatToRusKeyboard(query);

            SearchTemplate result = new SearchTemplate()
            {
                Fam = "",
                Im  = "",
                Ot  = "",
                Dr  = null
            };

            if (query.Length == 3)
            {
                result.Fam = query[0].ToString();
                result.Im  = query[1].ToString();
                result.Ot  = query[2].ToString();
                return(result);
            }

            if (query.Length == 11)
            {
                string manDateR = query.Substring(3, 8);

                int  res;
                bool isInt = Int32.TryParse(manDateR, out res);

                if (isInt)
                {
                    result.Fam = query[0].ToString();
                    result.Im  = query[1].ToString();
                    result.Ot  = query[2].ToString();
                    result.Dr  = new DateTime(Convert.ToInt32(manDateR.Substring(4, 4)), Convert.ToInt32(manDateR.Substring(2, 2)), Convert.ToInt32(manDateR.Substring(0, 2)));
                    return(result);
                }
            }

            if (query.IndexOf(' ') != -1)
            {
                string[] arr = query.Split(' ');

                result.Fam = arr[0];

                if (arr.Length > 1)
                {
                    result.Im = arr[1];
                }

                if (arr.Length > 2)
                {
                    result.Ot = arr[2];
                }

                return(result);
            }

            result.Fam = query;

            return(result);
        }
        /// <summary>
        /// Парсит входящую строку query и разбивает на поля имя,отч,фам,др
        /// понимает 3 символа, фио01012000, фам им отч
        /// предварительно преобразовывает qwerty в йцукен
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        private SearchTemplate ParseFioQuery(string query)
        {
            query = LatToRusKeyboard(query);

            SearchTemplate result = new SearchTemplate()
            {
                Fam = "",
                Im = "",
                Ot = "",
                Dr = null
            };

            if (query.Length == 3)
            {
                result.Fam = query[0].ToString();
                result.Im = query[1].ToString();
                result.Ot = query[2].ToString();
                return result;
            }

            if (query.Length == 11)
            {
                string manDateR = query.Substring(3, 8);

                int res;
                bool isInt = Int32.TryParse(manDateR, out res);

                if (isInt)
                {
                    result.Fam = query[0].ToString();
                    result.Im = query[1].ToString();
                    result.Ot = query[2].ToString();
                    result.Dr = new DateTime(Convert.ToInt32(manDateR.Substring(4, 4)), Convert.ToInt32(manDateR.Substring(2, 2)), Convert.ToInt32(manDateR.Substring(0, 2)));
                    return result;
                }
            }

            if (query.IndexOf(' ') != -1)
            {
                string[] arr = query.Split(' ');

                result.Fam = arr[0];

                if (arr.Length > 1)
                    result.Im = arr[1];

                if (arr.Length > 2)
                    result.Ot = arr[2];

                return result;
            }

            result.Fam = query;

            return result;
        }