コード例 #1
0
        /// <summary>
        /// Checks if input date matches selected date filter.
        /// </summary>
        /// <param name="date">String date in miliseconds.</param>
        /// <returns>True if date matches query, false in any other case.</returns>
        public bool IsMatching(string date)
        {
            if (!IsEnabled)
            {
                return(true);
            }
            DateOperations operations      = new DateOperations();
            DateTime       selectedMinDate = DateTime.Parse(ChosenMinDate, new CultureInfo("en-US"));
            DateTime       selectedMaxDate = DateTime.Parse(ChosenMaxDate, new CultureInfo("en-US"));

            DateTime resultDate = operations.MilisecondsToDateTime(Convert.ToInt64(date));

            switch (DateOption)
            {
            case DateOptionType.At:
                if (resultDate.Date == selectedMinDate.Date)
                {
                    return(true);
                }
                break;

            case DateOptionType.After:
                if (resultDate.Date >= selectedMinDate.Date)
                {
                    return(true);
                }
                break;

            case DateOptionType.Before:
                if (resultDate.Date <= selectedMinDate.Date)     //ChosenMinDate property is used for single argument filters
                {
                    return(true);
                }
                break;

            case DateOptionType.Between:
                if (selectedMinDate.Date > selectedMaxDate.Date)
                {
                    var temp = selectedMinDate;
                    selectedMinDate = selectedMaxDate;
                    selectedMaxDate = temp;
                }
                if ((resultDate.Date >= selectedMinDate.Date) && (resultDate.Date <= selectedMaxDate.Date))
                {
                    return(true);
                }
                break;
            }
            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Method to prepare new results with right date and GPS location.
        /// </summary>
        public void PreapreResultsForTests()
        {
            DateOperations operationsOnDate = new DateOperations();

            // Wynik 1_1: Data utworzenia: 2/2/2010,  szerokość: 52, długość: 21 (Warszawa)
            Survey survey = new Survey();
            survey.Display(Convert.ToInt32(SurveyId));
            survey.ResultInfo.Title = "test1";
            survey.ResultInfo.Latitude = "52";
            survey.ResultInfo.Longitude = "21";
            XDocument documentXML = survey.PrepareResultDocument();
            survey.ResultInfo.Time = operationsOnDate.DateTimeToMiliseconds(new DateTime(2010, 2, 2)).ToString();

            SavetTestResult(survey, documentXML);

            // Wynik 1_2: Data utworzenia: 2/24/2010, bez GPS
            Survey survey1 = new Survey();
            survey1.Display(Convert.ToInt32(SurveyId));
            survey1.ResultInfo.Title = "test2";
            XDocument documentXML1 = survey1.PrepareResultDocument();
            survey1.ResultInfo.Time = operationsOnDate.DateTimeToMiliseconds(new DateTime(2010, 2, 24)).ToString();
            if (documentXML1.Element("latitude") != null)
                documentXML1.Element("latitude").Remove();

            if (documentXML1.Element("longitude") != null)
                documentXML1.Element("longitude").Remove();

            SavetTestResult(survey1, documentXML1);

            // Wynik 1_3: Data utworzenia: 5/10/2010,  szerokość: 50, długość: 20 (Kraków)
            Survey survey2 = new Survey();
            survey2.Display(Convert.ToInt32(SurveyId));
            survey2.ResultInfo.Title = "test3";
            survey2.ResultInfo.Latitude = "50";
            survey2.ResultInfo.Longitude = "20";
            XDocument documentXML2 = survey2.PrepareResultDocument();
            survey2.ResultInfo.Time = operationsOnDate.DateTimeToMiliseconds(new DateTime(2010, 5, 10)).ToString();
            SavetTestResult(survey2, documentXML2);

            // Wynik 2_1: Data utworzenia: 2/2/2011,  szerokość: 50, długość: 19 (Katowice)
            Survey survey3 = new Survey();
            survey3.Display(Convert.ToInt32(SurveyId));
            survey3.ResultInfo.Title = "test4";
            survey3.ResultInfo.Latitude = "50";
            survey3.ResultInfo.Longitude = "19";
            XDocument documentXML3 = survey3.PrepareResultDocument();
            survey3.ResultInfo.Time = operationsOnDate.DateTimeToMiliseconds(new DateTime(2011, 2, 2)).ToString();
            SavetTestResult(survey3, documentXML3);

            // Wynik 2_2: Data utworzenia: 10/2/2011, szerokość: 50, długość: 20 (Kraków)
            Survey survey4 = new Survey();
            survey4.Display(Convert.ToInt32(SurveyId));
            survey4.ResultInfo.Title = "test5";
            survey4.ResultInfo.Latitude = "50";
            survey4.ResultInfo.Longitude = "20";
            XDocument documentXML4 = survey4.PrepareResultDocument();
            survey4.ResultInfo.Time = operationsOnDate.DateTimeToMiliseconds(new DateTime(2011, 10, 2)).ToString();
            SavetTestResult(survey4, documentXML4);

            // Wynik 3_1: Data utworzenia: 10/2/2011,  szerokość: 51, długość: 17 (Wrocław)
            Survey survey5 = new Survey();
            survey5.Display(Convert.ToInt32(SurveyId));
            survey5.ResultInfo.Title = "test6";
            survey5.ResultInfo.Latitude = "51";
            survey5.ResultInfo.Longitude = "17";
            XDocument documentXML5 = survey5.PrepareResultDocument();
            survey5.ResultInfo.Time = operationsOnDate.DateTimeToMiliseconds(new DateTime(2011, 10, 2)).ToString();

            SavetTestResult(survey5, documentXML5);
        }