Beispiel #1
0
        public Record(string firstname, string lastname, DateTime beginning, DateTime end)
        {
            FirstName = firstname;
            LastName  = lastname;

            Month = beginning.Month;
            Year  = beginning.Year;

            Beginning = beginning.ToString("H:mm");
            Ending    = end.ToString("H:mm");

            StartDay = beginning.Day;
            EndDay   = end.Day;

            //Property Begin se musí nastavit před property Time, protože Time s ní následně pracuje!
            Begin = beginning;
            End   = end;
            Time  = (end - beginning).ToString();

            if (StartDay == EndDay)
            {
                ConcatDay = StartDay.ToString();
            }
            else if (StartDay != EndDay & EndDay == 0)
            {
                ConcatDay = StartDay.ToString();
            }
            else
            {
                ConcatDay = StartDay + " až " + EndDay;
            }
        }
        public string Load(string url)
        {
            var param   = new AkpReportParameters().GetParameters();
            var browser = Browser.GetBrowser();

            param.formParams["ctl00_ContentPlaceHolder1_Date1"] = StartDay.ToString("dd.MM.yyyy");
            param.formParams["ctl00_ContentPlaceHolder1_Date2"] = EndDate.ToString("dd.MM.yyyy");

            var reportPage = browser.NavigateToPage(new Uri(url));
            var form       = reportPage.FindForm(param.formId);

            foreach (string key in param.formParams)
            {
                form[key] = param.formParams[key];
            }
            foreach (string key in param.headParams)
            {
                browser.Headers.Add(key, param.headParams[key]);
            }
            form.Method = HttpVerb.Post;
            WebPage response = form.Submit();

            return(JObject.Parse(response)["result"].ToString());
        }
        public bool IsPlannable(IEnumerable <Course> courses, int priority, string code)
        {
            // dont do anything when this status already is unplannable...
            if (this.Status == Status.UNPLANNABLE)
            {
                return(false);
            }

            _logger.Debug("IsPlannable");

            if (!this.Intersects(courses))
            {
                _logger.Debug(string.Format(_culture, "Course with code {0} and startdate {1} doesn't intersect with other course", code, StartDay.ToString("dd-MM-yyyy")));
                return(true);
            }

            if (this.IntersectsOnlyWithStatus(courses, Status.UNPLANNABLE))
            {
                _logger.Debug(string.Format(_culture, "Course with code {0} and startdate {1} intersects only with unplannable implementations", code, StartDay.ToString("dd-MM-yyyy")));
                return(true);
            }

            if (this.IntersectsWithStatus(courses, Status.PLANNED))
            {
                _logger.Debug(string.Format(_culture, "Course with code {0} and startdate {1} intersects with planned implementation", code, StartDay.ToString("dd-MM-yyyy")));
                return(false);
            }

            return(true);

            List <string> scannedCourses = new List <string>();

            var coursesToCheck = courses.Where(course => course.Code != code).ToList();

            //Add self for intersection
            coursesToCheck.Add(new Course
            {
                Code     = code,
                Priority = priority,
                CourseImplementations = new List <CourseImplementation>
                {
                    this,
                },
            });

            _logger.Debug(string.Format(_culture, "Course with code {0} and startdate {1} returns IsPlannable", code, StartDay.ToString("dd-MM-yyyy")));

            return(IsPlannable(coursesToCheck, scannedCourses, priority));
        }
        private bool IsPlannable(IEnumerable <Course> courses, List <string> scannedCourses, int priority)
        {
            _logger.Debug(string.Format(_culture, "private IsPlannable with startdate {0}", StartDay.ToString("dd-MM-yyyy")));
            bool plannable = false;

            if (this.GetIntersectedCourseImplementations(courses).All(ci => ci.Status == Status.PLANNED))
            {
                _logger.Debug("All intersected course implementations are planned");
                return(false);
            }

            var notPlannedIntersectedCourses = this.GetIntersectedCourses(courses)
                                               .Where(course => course.CourseImplementations.All(ci => ci.Status != Status.PLANNED) && course.Priority <= priority);
            var notPlannedIntersectedCoursesWithoutScanned = notPlannedIntersectedCourses.Where(intersectedCourse => !scannedCourses.Contains(intersectedCourse.Code)).ToList();

            foreach (var intersectedCourse in notPlannedIntersectedCoursesWithoutScanned)
            {
                scannedCourses.Add(intersectedCourse.Code);

                if (intersectedCourse.HasIntersectedCourseWithFreeImplementation(courses, priority))
                {
                    _logger.Debug(string.Format(_culture, "Inersected course {0} intersects with course with free implementation", intersectedCourse.Code));
                    return(true);
                }

                if (!plannable)
                {
                    _logger.Debug(string.Format(_culture, "plannable is false recursive IsPlannable all implementations from instersected course {0}", intersectedCourse.Code));
                    plannable = intersectedCourse.CourseImplementations.Any(ci => ci.IsPlannable(courses, scannedCourses, priority));
                }
            }

            _logger.Debug(string.Format(_culture, "return plannable {0}", plannable));
            return(plannable);
        }
Beispiel #5
0
 public override string ToString()
 {
     return(StartDay.ToString() + ";" + EndDay.ToString());
 }