예제 #1
0
        private void BuildPageFromResults()
        {
            UPMCalendarPage calendarPage = (UPMCalendarPage)this.Page;

            calendarPage.CalendarItems = this.CalendarItemsFromResult();

            if (this.viewType == UPCalendarViewType.Day || this.viewType == UPCalendarViewType.List)
            {
                string sortSequence                    = this.ViewReference.ContextValueForKey("SortSequence");
                bool   isDescending                    = sortSequence != null && sortSequence == "DESC";
                List <ICalendarItem>    sorted         = calendarPage.CalendarItems.Sort(!isDescending);
                List <UPMResultSection> resultSections = sorted.ResultSectionsForData(null, null);
                this.SearchPage.RemoveAllChildren();
                foreach (UPMResultSection section in resultSections)
                {
                    this.SearchPage.AddResultSection(section);
                }

                UPMAction goToAction = new UPMAction(StringIdentifier.IdentifierWithStringId("action"));
                goToAction.SetTargetAction(this, this.SwitchToDetail);
                goToAction.LabelText   = LocalizedString.TextShowRecord;
                calendarPage.RowAction = goToAction;
            }

            this.Page.Invalid = false;
            base.InformAboutDidChangeTopLevelElement(this.TopLevelElement, this.TopLevelElement, null, null);
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TimelineCalendarPageModelController"/> class.
        /// </summary>
        /// <param name="viewReference">The view reference.</param>
        public TimelineCalendarPageModelController(ViewReference viewReference)
            : base(viewReference)
        {
            this.RecordIdentification  = viewReference.ContextValueForKey("RecordId");
            this.TimelineConfiguration = ConfigurationUnitStore.DefaultStore.TimelineByName(viewReference.ContextValueForKey("TimelineConfigName"));
            if (string.IsNullOrEmpty(this.RecordIdentification) || this.TimelineConfiguration == null)
            {
                throw new Exception("Something wrong");
            }

            this.RequestOption = UPCRMDataStore.RequestOptionFromString(viewReference.ContextValueForKey("RequestOption"), UPRequestOption.FastestAvailable);
            RecordIdentifier identifier   = new RecordIdentifier(this.RecordIdentification);
            UPMCalendarPage  calendarPage = new UPMCalendarPage(identifier)
            {
                DefaultViewType       = SearchPageViewType.CalendarMonth,
                IncludeSystemCalendar = viewReference.ContextValueForKey("IncludeSystemCalendar").ToBoolWithDefaultValue(true),
                Invalid = true,

                AvailableViewTypes = new List <SearchPageViewType>
                {
                    SearchPageViewType.CalendarDay,
                    SearchPageViewType.CalendarWeek,
                    SearchPageViewType.CalendarMonth,
                    SearchPageViewType.CalendarList
                }
            };

            this.TopLevelElement = calendarPage;
        }
예제 #3
0
        /// <summary>
        /// Searches the specified search page.
        /// </summary>
        /// <param name="searchPage">The search page.</param>
        public override void Search(object searchPage)
        {
            if (this.TimelineSearches == null)
            {
                this.TimelineSearches = new List <UPSearchPageModelControllerPreparedSearch>();
                foreach (ConfigTimelineInfoArea timelineInfoArea in this.TimelineConfiguration.InfoAreas)
                {
                    UPSearchPageModelControllerPreparedSearch preparedSearch = new UPSearchPageModelControllerPreparedSearch(timelineInfoArea);
                    this.TimelineSearches.Add(preparedSearch);
                }
            }

            UPMCalendarPage calendarPage = (UPMCalendarPage)this.Page;

            this.fromDate = calendarPage.CalendarFromDate;
            this.toDate   = calendarPage.CalendarToDate;
            string fromDateString = this.fromDate?.CrmValueFromDate();
            string toDateString   = this.toDate?.CrmValueFromDate();
            int    searchCount    = this.TimelineSearches.Count;

            this.searches = new List <TimelineSearch>();

            for (int i = 0; i < searchCount; i++)
            {
                UPSearchPageModelControllerPreparedSearch preparedSearch = this.TimelineSearches[i];
                UPContainerMetaInfo crmQuery = preparedSearch.CrmQueryForValue(null, null, false);
                if (!string.IsNullOrEmpty(fromDateString))
                {
                    UPInfoAreaCondition fromCondition = new UPInfoAreaConditionLeaf(preparedSearch.TimelineConfiguration.InfoAreaId, preparedSearch.TimelineConfiguration.DateField.FieldId, ">=", fromDateString);
                    crmQuery.RootInfoAreaMetaInfo.AddCondition(fromCondition);
                }

                if (!string.IsNullOrEmpty(toDateString))
                {
                    int dateFieldIndex;
                    dateFieldIndex = preparedSearch.TimelineConfiguration.EndDateField?.FieldId ?? preparedSearch.TimelineConfiguration.DateField.FieldId;

                    UPInfoAreaCondition toCondition = new UPInfoAreaConditionLeaf(preparedSearch.TimelineConfiguration.InfoAreaId, dateFieldIndex, "<=", toDateString);
                    crmQuery.RootInfoAreaMetaInfo.AddCondition(toCondition);
                }

                crmQuery.SetLinkRecordIdentification(this.RecordIdentification, preparedSearch.TimelineConfiguration.LinkId);
                this.searches.Add(new TimelineSearch(crmQuery, preparedSearch));
            }

            this.nextSearch = 0;
            this.ExecuteNextSearch();
        }