Пример #1
0
        private string LoadRootRecordIdentification()
        {
            string rootIdentification;

            // load objectives linked to a call
            if (!string.IsNullOrEmpty(this.ParentLink))
            {
                UPContainerMetaInfo personLoadContainer = new UPContainerMetaInfo(Constants.PersonInfoArea);
                personLoadContainer.SetLinkRecordIdentification(this.RecordIdentification);
                UPCRMResult personResult = personLoadContainer.Find();

                // person related record...load objectives for person
                if (personResult.RowCount == 1)
                {
                    rootIdentification = personResult.ResultRowAtIndex(0).RootRecordIdentification;
                }
                else
                {
                    // company related record..load objectives for company
                    UPContainerMetaInfo companyLoadContainer = new UPContainerMetaInfo(Constants.AccountInfoArea);
                    companyLoadContainer.SetLinkRecordIdentification(this.RecordIdentification);
                    UPCRMResult companyResult = companyLoadContainer.Find();
                    rootIdentification = companyResult.RowCount == 1
                        ? companyResult.ResultRowAtIndex(0).RootRecordIdentification
                        : this.RecordIdentification;
                }
            }
            else
            {
                rootIdentification = this.RecordIdentification;
            }

            return(rootIdentification);
        }
        private UPContainerMetaInfo Query()
        {
            if (this.QueryConfiguration == null)
            {
                return(null);
            }

            UPContainerMetaInfo query = new UPContainerMetaInfo(this.QueryConfiguration, this.FilterParameters);

            if (query == null)
            {
                return(null);
            }

            query.DisableVirtualLinks = true;
            if (this.LinkRecordIdentification?.Length > 0)
            {
                query.SetLinkRecordIdentification(this.LinkRecordIdentification, this.LinkId);
            }

            if (this.AnalysisConditions?.Count > 0)
            {
                // currently not implemented (analysis conditions are not set, and so do not influence the query)
            }

            return(query);
        }
Пример #3
0
        /// <summary>
        /// Copies the field values for record identification.
        /// </summary>
        /// <param name="recordIdentification">The record identification.</param>
        /// <param name="alwaysRemote">if set to <c>true</c> [always remote].</param>
        /// <param name="theDelegate">The delegate.</param>
        /// <returns></returns>
        public Operation CopyFieldValuesForRecordIdentification(string recordIdentification, bool alwaysRemote, UPCopyFieldsDelegate theDelegate)
        {
            if (!alwaysRemote)
            {
                Dictionary <string, object> dict = this.CopyFieldValuesForRecordIdentification(recordIdentification);
                if (dict?.Count > 0)
                {
                    theDelegate?.CopyFieldsDidFinishWithValues(this, dict);
                    return(null);
                }
            }

            UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(this.FieldControlConfiguration);

            crmQuery.SetLinkRecordIdentification(recordIdentification);
            UPCopyFieldsRequest request = new UPCopyFieldsRequest(crmQuery, theDelegate, this);

            request.AlwaysRemote = true;

            if (this.requests == null)
            {
                this.requests = new List <UPCopyFieldsRequest>();
            }

            this.requests.Add(request);

            return(request.Start());
        }
        private void UpdatePage(UPContainerMetaInfo containerMetaInfo)
        {
            if (this.RequestOption != UPRequestOption.Offline)
            {
                // read record asynchronously online
                Operation operation;
                if (string.IsNullOrWhiteSpace(this.LinkRecordIdentification))
                {
                    operation = containerMetaInfo.ReadRecord(this.recordId, UPRequestOption.Online, this);
                }
                else
                {
                    containerMetaInfo.DisableVirtualLinks = true;
                    containerMetaInfo.SetLinkRecordIdentification(this.LinkRecordIdentification, this.LinkId);
                    operation = containerMetaInfo.Find(UPRequestOption.Online, this);
                }

                if (operation == null)
                {
                    this.UpdatePageWithResult(null);
                }
            }
            else
            {
                this.UpdatePageWithResult(null);
            }
        }
Пример #5
0
        /// <summary>
        /// The query for link link record.
        /// </summary>
        /// <param name="linkInfo">
        /// The link info.
        /// </param>
        /// <param name="recordIdentification">
        /// The record identification.
        /// </param>
        /// <returns>
        /// The <see cref="UPContainerMetaInfo"/>.
        /// </returns>
        public UPContainerMetaInfo QueryForLinkLinkRecord(UPCRMLinkInfo linkInfo, string recordIdentification)
        {
            UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(null, linkInfo.TargetInfoAreaId);

            crmQuery.SetLinkRecordIdentification(recordIdentification, linkInfo.LinkId);
            return(crmQuery);
        }
Пример #6
0
        /// <summary>
        /// Copies the field values for record identification.
        /// </summary>
        /// <param name="recordIdentification">The record identification.</param>
        /// <returns></returns>
        public Dictionary <string, object> CopyFieldValuesForRecordIdentification(string recordIdentification)
        {
            UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(this.FieldControlConfiguration);

            crmQuery.SetLinkRecordIdentification(recordIdentification);
            UPCRMResult result = crmQuery.Find();

            return(result.RowCount >= 1 ? this.CopyFieldValuesForResult((UPCRMResultRow)result.ResultRowAtIndex(0)) : null);
        }
        /// <summary>
        /// The document data for record id.
        /// </summary>
        /// <param name="recordId">
        /// The record id.
        /// </param>
        /// <returns>
        /// The <see cref="DocumentData"/>.
        /// </returns>
        public DocumentData DocumentDataForRecordId(string recordId)
        {
            UPContainerMetaInfo query = new UPContainerMetaInfo(this.FieldControl);

            query.SetLinkRecordIdentification(this.InfoAreaId.InfoAreaIdRecordId(recordId));
            UPCRMResult result = query.Find();

            return(result.RowCount > 0 ? this.DocumentDataForResultRow(result.ResultRowAtIndex(0) as UPCRMResultRow) : null);
        }
Пример #8
0
        /// <summary>
        /// CRMs the query for record identification.
        /// </summary>
        /// <param name="recordIdentification">The record identification.</param>
        /// <returns></returns>
        public UPContainerMetaInfo CrmQueryForRecordIdentification(string recordIdentification)
        {
            var crmQuery = new UPContainerMetaInfo(new List <UPCRMField>(), recordIdentification.InfoAreaId());

            if (this.Filter != null)
            {
                crmQuery.ApplyFilter(this.Filter);
            }

            crmQuery.SetLinkRecordIdentification(recordIdentification);
            return(crmQuery);
        }
        private UPMGroup GroupFromRow(UPCRMResultRow resultRow)
        {
            if (resultRow.IsNewRow)
            {
                if (this.AddRecordEnabled)
                {
                    this.Group           = this.GroupFromChildResult(null);
                    this.ControllerState = GroupModelControllerState.Finished;
                }
                else
                {
                    this.Group           = null;
                    this.ControllerState = GroupModelControllerState.Empty;
                }

                return(this.Group);
            }

            UPContainerMetaInfo childMetaInfo = new UPContainerMetaInfo(this.ChildFieldControl);

            this.LinkRecordIdentification = resultRow.RootRecordIdentification;
            childMetaInfo.SetLinkRecordIdentification(this.LinkRecordIdentification, this.LinkId);
            if (this.RequestOption == UPRequestOption.Offline || this.RequestOption == UPRequestOption.FastestAvailable)
            {
                UPCRMResult childResult = childMetaInfo.Find();
                if (childResult.RowCount > 0)
                {
                    this.ControllerState = GroupModelControllerState.Finished;
                    return(this.GroupFromChildResult(childResult));
                }
            }

            if (this.RequestOption != UPRequestOption.Offline)
            {
                Operation operation = childMetaInfo.Find(this);
                if (operation != null)
                {
                    this.ControllerState = GroupModelControllerState.Error;
                    return(null);
                }
                else
                {
                    this.ControllerState = GroupModelControllerState.Pending;
                    return(null);
                }
            }
            else
            {
                this.ControllerState = GroupModelControllerState.Empty;
                return(this.GroupFromChildResult(null));
            }
        }
        /// <summary>
        /// Records the exists offline.
        /// </summary>
        /// <param name="recordIdentification">
        /// The record identification.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool RecordExistsOffline(string recordIdentification)
        {
            if (recordIdentification == null)
            {
                return(false);
            }

            var crmQuery = new UPContainerMetaInfo(null, recordIdentification.InfoAreaId());

            crmQuery.SetLinkRecordIdentification(recordIdentification);
            var result = crmQuery.Find();

            return(result?.RowCount > 0);
        }
Пример #11
0
        private void ProcessConfiguration(
            IEnumerable <object> listConfigurations,
            bool noLink,
            string parentRecordIdentification)
        {
            var duplicatePostfix = 0;

            foreach (var configName in listConfigurations)
            {
                var crmQuery = new UPContainerMetaInfo(configName as string, this.FilterParameters);
                if (!noLink && !string.IsNullOrEmpty(parentRecordIdentification))
                {
                    crmQuery.SetLinkRecordIdentification(parentRecordIdentification);
                }

                var result = crmQuery.Find();
                var count  = result.RowCount;
                for (var index = 0; index < count; index++)
                {
                    var option = new UPSelectorOption(
                        result.ResultRowAtIndex(index) as UPCRMResultRow,
                        crmQuery.SourceFieldControl);
                    if (this.PossibleValues == null)
                    {
                        this.PossibleValues = new Dictionary <string, UPSelectorOption> {
                            { option.Name, option }
                        };
                        this.ExplicitKeyOrder = new List <string> {
                            option.Name
                        };
                        this.PossibleValuesWithLabel = new Dictionary <string, object> {
                            { option.Name, option.Name }
                        };
                    }
                    else if (this.PossibleValues.ValueOrDefault(option.Name) == null)
                    {
                        this.PossibleValues[option.Name] = option;
                        this.ExplicitKeyOrder.Add(option.Name);
                        this.PossibleValuesWithLabel[option.Name] = option.Name;
                    }
                    else if (this.Definition.ValueOrDefault("DuplicateNames").ToInt() != 0)
                    {
                        var key = $"{option.Name}_{++duplicatePostfix}";
                        this.PossibleValues[key] = option;
                        this.ExplicitKeyOrder.Add(key);
                        this.PossibleValuesWithLabel[key] = option.Name;
                    }
                }
            }
        }
        private UPCRMResult GetResultFromContainerMetaInfo(IConfigurationUnitStore configStore)
        {
            UPCRMResult result = null;

            var containerMetaInfo = new UPContainerMetaInfo(this.detailsControl)
            {
                ReplaceCaseSensitiveCharacters =
                    configStore.ConfigValueIsSet("Search.ReplaceCaseSensitiveCharacters")
            };

            // read record synchronously offline
            if (this.RequestOption == UPRequestOption.Default ||
                this.RequestOption == UPRequestOption.FastestAvailable ||
                this.RequestOption == UPRequestOption.Offline)
            {
                if (string.IsNullOrWhiteSpace(this.LinkRecordIdentification))
                {
                    result = containerMetaInfo.ReadRecord(
                        StringExtensions.InfoAreaIdRecordId(this.infoAreaId, this.recordId));
                }
                else
                {
                    containerMetaInfo.SetLinkRecordIdentification(this.LinkRecordIdentification, this.LinkId);
                    containerMetaInfo.DisableVirtualLinks = true;
                    result = containerMetaInfo.Find();
                    if (result.RowCount >= 1)
                    {
                        this.recordId = result.ResultRowAtIndex(0).RootRecordId;
                    }
                }
            }

            if (result == null || result.RowCount < 1)
            {
                this.UpdatePage(containerMetaInfo);
            }
            else
            {
                var resultRow = result.ResultRowAtIndex(0) as UPCRMResultRow;
                this.ApplySubTitleFromResultRow(resultRow);
                this.FillPageWithResultRow(
                    this.Page,
                    resultRow,
                    (resultRow?.IsServerResponse ?? true) ? UPRequestOption.Online : UPRequestOption.Offline);
            }

            return(result);
        }
Пример #13
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();
        }
        /// <summary>
        /// Searches the operation did fail with error.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="error">The error.</param>
        public void SearchOperationDidFailWithError(Operation operation, Exception error)
        {
            if (this.RequestOption == UPRequestOption.BestAvailable && error.IsConnectionOfflineError())
            {
                UPContainerMetaInfo childMetaInfo = new UPContainerMetaInfo(this.ChildFieldControl);
                childMetaInfo.SetLinkRecordIdentification(this.LinkRecordIdentification, this.LinkId);
                UPCRMResult childResult = childMetaInfo.Find();
                this.ControllerState = childResult.RowCount > 0 ? GroupModelControllerState.Finished : GroupModelControllerState.Empty;
            }
            else
            {
                this.ControllerState = GroupModelControllerState.Error;
            }

            this.Delegate.GroupModelControllerFinished(this);
        }
        /// <summary>
        /// The start.
        /// </summary>
        /// <param name="requestOption">
        /// The request option.
        /// </param>
        public void Start(UPRequestOption requestOption)
        {
            Dictionary <string, UPCRMField> fields = this.rootExpand?.FieldsForAlternateExpands(true);

            if (fields == null || fields?.Count == 0)
            {
                this.SearchOperationDidFinishWithResult(null, null);
                return;
            }

            var fieldValues = fields.Values.Select(x => x).ToList();
            var crmQuery    = new UPContainerMetaInfo(fieldValues, this.rootExpand.InfoAreaId);

            crmQuery.SetLinkRecordIdentification(this.recordIdentification);
            crmQuery.Find(requestOption, this);
        }
Пример #16
0
        /// <summary>
        /// The server query.
        /// </summary>
        /// <returns>
        /// The <see cref="UPContainerMetaInfo"/>.
        /// </returns>
        public UPContainerMetaInfo ServerQuery()
        {
            List <UPCRMField> serverLinkFields = new List <UPCRMField>();

            foreach (UPCRMLinkReaderLinkContext context in this.linkContexts)
            {
                serverLinkFields.Add(
                    UPCRMField.FieldWithFieldIdInfoAreaIdLinkId(
                        0,
                        context.LinkInfo.TargetInfoAreaId,
                        context.LinkInfo.LinkId));
            }

            UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(serverLinkFields, this.InfoAreaId);

            crmQuery.SetLinkRecordIdentification(this.SourceRecordIdentification, -1);
            return(crmQuery);
        }
        /// <summary>
        /// Loads the documents with maximum results.
        /// </summary>
        /// <param name="maxResults">The maximum results.</param>
        public void LoadDocumentsWithMaxResults(int maxResults)
        {
            if (this.Record != null)
            {
                IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
                this.documentFieldControl = configStore.FieldControlByNameFromGroup("List", "D3DocData");
                UPContainerMetaInfo containerMetaInfo = new UPContainerMetaInfo(this.documentFieldControl);
                containerMetaInfo.SetLinkRecordIdentification(this.Record.OriginalRecordIdentification, 127);
                if (maxResults > 0)
                {
                    containerMetaInfo.MaxResults = maxResults;
                }

                Operation operation = containerMetaInfo.Find(this.Group.Objectives.RequestOption, this);
                if (operation == null)
                {
                    //DDLogError("Could not create operation for loading documents.{}");
                    Logger.LogError($"Could not create operation for loading documents. {this.Group.Objectives.RequestOption.ToString()}");
                }
            }
        }
Пример #18
0
        /// <summary>
        /// Creates the query link identifier search and list.
        /// </summary>
        /// <param name="recordIdentifier">The record identifier.</param>
        /// <param name="linkId">The link identifier.</param>
        /// <param name="searchAndList">The search and list.</param>
        /// <returns></returns>
        protected UPContainerMetaInfo CreateQueryLinkIdSearchAndList(string recordIdentifier, int linkId, SearchAndList searchAndList)
        {
            if (searchAndList == null)
            {
                return(null);
            }

            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            if (this.expandSettings == null)
            {
                this.expandSettings = configStore.ExpandByName(searchAndList.InfoAreaId);
            }

            FieldControl fieldControlList  = configStore.FieldControlByNameFromGroup("List", searchAndList.FieldGroupName);
            FieldControl fieldControlMini  = configStore.FieldControlByNameFromGroup("MiniDetails", searchAndList.FieldGroupName);
            FieldControl fieldControlCombi = new FieldControl(new List <FieldControl> {
                fieldControlList, fieldControlMini
            });
            UPContainerMetaInfo query = new UPContainerMetaInfo(fieldControlCombi);

            query.SetLinkRecordIdentification(recordIdentifier, linkId);
            if (this.expandSettings != null)
            {
                Dictionary <string, UPCRMField> alternateExpandFields = this.expandSettings.FieldsForAlternateExpands(true);
                List <UPCRMField> additionalFields = alternateExpandFields.Values.Where(field => query.ContainsField(field) == null).ToList();

                if (additionalFields.Count > 0)
                {
                    query.AddCrmFields(additionalFields);
                }

                this.expandChecker = this.expandSettings.ExpandCheckerForCrmQuery(query);
            }

            return(query);
        }
Пример #19
0
        /// <summary>
        /// The client query.
        /// </summary>
        /// <returns>
        /// The <see cref="UPContainerMetaInfo"/>.
        /// </returns>
        public UPContainerMetaInfo ClientQuery()
        {
            List <UPCRMField>     fieldArray     = this.FieldArray();
            List <UPCRMLinkField> linkfieldArray = this.LinkFieldArrayWithStartIndex(fieldArray?.Count ?? 0);

            if (linkfieldArray != null)
            {
                if (fieldArray == null)
                {
                    fieldArray = linkfieldArray.Cast <UPCRMField>().ToList();
                }
                else
                {
                    List <UPCRMField> fa = new List <UPCRMField>(fieldArray);
                    fa.AddRange(linkfieldArray);
                    fieldArray = fa;
                }
            }

            UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(fieldArray, this.InfoAreaId);

            crmQuery.SetLinkRecordIdentification(this.SourceRecordIdentification, -1);
            return(crmQuery);
        }
Пример #20
0
        private bool ProcessNoLink(string linkInfoAreaId, ref string parentRecordIdentification)
        {
            if (string.IsNullOrWhiteSpace(linkInfoAreaId))
            {
                linkInfoAreaId = this.InfoAreaId;
                if (string.IsNullOrWhiteSpace(linkInfoAreaId))
                {
                    return(true);
                }
            }

            if (linkInfoAreaId.Equals(this.RecordIdentification.InfoAreaId()))
            {
                parentRecordIdentification = this.RecordIdentification;
            }
            else if (!string.IsNullOrWhiteSpace(this.RecordIdentification))
            {
                var crmQuery = new UPContainerMetaInfo(new List <UPCRMField>(), linkInfoAreaId)
                {
                    DisableVirtualLinks = true
                };

                crmQuery.SetLinkRecordIdentification(this.RecordIdentification, this.LinkId);
                var result = crmQuery.Find();
                if (result.RowCount > 0)
                {
                    parentRecordIdentification = result.ResultRowAtIndex(0).RootRecordId;
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// Results for row.
        /// </summary>
        /// <param name="serialEntryRow">The serial entry row.</param>
        /// <returns></returns>
        public override UPSerialEntryInfoResult ResultForRow(UPSERow serialEntryRow)
        {
            string sourceRecordIdentification           = StringExtensions.InfoAreaIdRecordId(serialEntryRow.SerialEntry.SourceInfoAreaId, serialEntryRow.RowRecordId);
            UPSerialEntryInfoResultFromCRMResult result = this.cachedResults.ValueOrDefault(sourceRecordIdentification);

            if (result != null)
            {
                return(result);
            }

            UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(this.FieldControl);

            if (!this.IgnoreSourceRecord)
            {
                crmQuery.SetLinkRecordIdentification(sourceRecordIdentification);
            }

            if (this.MaxResults > 0)
            {
                crmQuery.MaxResults = this.MaxResults;
            }

            if (this.Filter != null)
            {
                Dictionary <string, object> parameterValues = serialEntryRow.SourceFunctionValues();
                if (this.SerialEntry.InitialFieldValuesForDestination.Count > 0)
                {
                    if (parameterValues.Count > 0)
                    {
                        Dictionary <string, object> dict = new Dictionary <string, object>(this.SerialEntry.InitialFieldValuesForDestination);
                        foreach (var entry in parameterValues)
                        {
                            dict[entry.Key] = entry.Value;
                        }

                        parameterValues = dict;
                    }
                    else
                    {
                        parameterValues = this.SerialEntry.InitialFieldValuesForDestination;
                    }
                }

                if (parameterValues.Count > 0)
                {
                    UPConfigFilter applyFilter = this.Filter.FilterByApplyingReplacements(UPConditionValueReplacement.ReplacementsFromValueParameterDictionary(parameterValues));
                    if (applyFilter != null)
                    {
                        crmQuery.ApplyFilter(applyFilter);
                    }
                }
                else
                {
                    crmQuery.ApplyFilter(this.Filter);
                }
            }

            UPCRMResult crmResult = crmQuery.Find();

            result = new UPSerialEntryInfoResultFromCRMResult(crmResult, this);
            if (this.cachedResults == null)
            {
                this.cachedResults = new Dictionary <string, UPSerialEntryInfoResultFromCRMResult> {
                    { sourceRecordIdentification, result }
                };
            }
            else
            {
                this.cachedResults[sourceRecordIdentification] = result;
            }

            return(result);
        }
        /// <summary>
        /// Offlines the request data online context did finish with result.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="data">The data.</param>
        /// <param name="online">if set to <c>true</c> [online].</param>
        /// <param name="context">The context.</param>
        /// <param name="result">The result.</param>
        public void OfflineRequestDidFinishWithResult(UPOfflineRequest request, object data, bool online, object context, Dictionary <string, object> result)
        {
            if (this.uploadDocumentRequest != null)
            {
                this.uploadDocumentRequest = null;
                if (this.disable85106)
                {
                    this.ApproveAction.PerformAction(this.approveActionDelegate);
                }

                this.pageBuilt = false;
                if (this.ParentOrganizerModelController is DetailOrganizerModelController)
                {
                    ((DetailOrganizerModelController)this.ParentOrganizerModelController).RefreshAfterDocumentUploaded(this.RecordIdentification);
                }

                if (!this.disable85106)
                {
                    this.ShouldWaitForPendingChanges = true;
                }
            }
            else
            {
                this.buttonRequest       = null;
                this.pageBuilt           = false;
                this.SerialEntryApproved = UPMSerialEntryState.Approved;
                if (!this.disable85106)
                {
                    this.ShouldWaitForPendingChanges = false;
                }
                else
                {
                    List <UPCRMRecord> records = (List <UPCRMRecord>)data;
                    if (records.Count > 0)
                    {
                        UPCRMRecord      record           = records[0];
                        RecordIdentifier recordIdentifier = new RecordIdentifier(record.RecordIdentification);
                        UPChangeManager.CurrentChangeManager.RegisterChanges(new List <IIdentifier> {
                            recordIdentifier
                        });
                        if (this.ParentOrganizerModelController is DetailOrganizerModelController)
                        {
                            List <IIdentifier> changes = UPChangeManager.CurrentChangeManager.ChangesToApplyForCurrentViewController();
                            if (this.sendByEmailFilter != null)
                            {
                                this.unreportedRecordChanges = changes;
                            }
                            else
                            {
                                this.ParentOrganizerModelController.ProcessChanges(changes);
                            }
                        }
                    }

                    if (this.sendByEmailFilter != null)
                    {
                        UPContainerMetaInfo _emailFilterQuery = new UPContainerMetaInfo(new List <UPCRMField>(), this.sendByEmailFilter.InfoAreaId);
                        this.emailFilterQuery = _emailFilterQuery;
                        _emailFilterQuery.ApplyFilter(this.sendByEmailFilter);
                        _emailFilterQuery.SetLinkRecordIdentification(this.RecordIdentification);
                        _emailFilterQuery.Find(UPRequestOption.FastestAvailable, this);
                    }
                    else
                    {
                        this.SetShouldWaitForPendingChangesWithoutPageUpdate(false, true);
                    }
                }
            }
        }
Пример #23
0
        /// <summary>
        /// Records the identification for link information area identifier link identifier.
        /// </summary>
        /// <param name="infoAreaId">
        /// The information area identifier.
        /// </param>
        /// <param name="linkId">
        /// The link identifier.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string RecordIdentificationForLinkInfoAreaIdLinkId(string infoAreaId, int linkId)
        {
            var position = this.Result.MetaInfo.IndexOfResultInfoAreaIdLinkId(infoAreaId, linkId);

            if (position >= 0)
            {
                return(this.RecordIdentificationAtIndex(position));
            }

            var rootInfoAreaId = this.PhysicalInfoAreaIdAtIndex(0);
            var tableInfo      = UPCRMDataStore.DefaultStore.TableInfoForInfoArea(rootInfoAreaId);
            var linkInfo       = tableInfo.LinkInfoForTargetInfoAreaIdLinkId(infoAreaId, linkId);

            if (linkInfo == null)
            {
                return(null);
            }

            if (linkInfo.IsFieldLink && linkInfo.LinkFieldArray?.Count == 1)
            {
                var arNoString = this.RawValueForFieldIdInfoAreaIdLinkId(
                    linkInfo.FirstField.FieldId,
                    linkInfo.InfoAreaId,
                    -1);
                if (string.IsNullOrEmpty(arNoString))
                {
                    return(null);
                }

                var crmQuery         = new UPContainerMetaInfo(new List <UPCRMField>(), linkInfo.TargetInfoAreaId);
                var infoAreaMetaInfo = crmQuery.RootInfoAreaMetaInfo;
                infoAreaMetaInfo.Condition = new UPInfoAreaConditionLeaf(
                    linkInfo.TargetInfoAreaId,
                    linkInfo.FirstField.TargetFieldId,
                    "=",
                    arNoString);
                var res = crmQuery.Find();
                if (res.RowCount > 0)
                {
                    return(res.ResultRowAtIndex(0).RootRecordIdentification);
                }
            }
            else if (linkInfo.HasColumn && !this.IsNewRow &&
                     !ConfigurationUnitStore.DefaultStore.ConfigValueIsSet("Disable.82339"))
            {
                var crmQuery = new UPContainerMetaInfo(new List <UPCRMField>(), rootInfoAreaId);
                crmQuery.AddCrmFields(
                    new List <UPCRMField>
                {
                    new UPCRMLinkField(linkInfo.TargetInfoAreaId, linkInfo.LinkId, rootInfoAreaId)
                });
                crmQuery.SetLinkRecordIdentification(this.RootRecordIdentification);
                var res = crmQuery.Find();
                if (res.RowCount != 1)
                {
                    return(null);
                }

                var linkRecordId = res.ResultRowAtIndex(0).RawValueAtIndex(0);
                if (!string.IsNullOrEmpty(linkRecordId))
                {
                    return(linkInfo.TargetInfoAreaId.InfoAreaIdRecordId(linkRecordId));
                }
            }

            SimpleIoc.Default.GetInstance <ILogger>().LogWarn($"RecordSelector: could not determine linkRecord for infoArea:{infoAreaId} linkId:{linkId}");
            return(null);
        }
Пример #24
0
        private void ContinueLoadWithFieldValueDictionary(Dictionary <string, object> fieldValueDictionary)
        {
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            if (fieldValueDictionary != null)
            {
                if (this.copyFieldsDictionary == null)
                {
                    this.copyFieldsDictionary = new Dictionary <string, Dictionary <string, object> >();
                }

                this.copyFieldsDictionary.SetObjectForKey(fieldValueDictionary, this.currentSectionConfiguration.SourceFieldControl.UnitName);
            }

            this.currentCopyFields = null;
            FieldControl   destinationFieldControl = this.currentSectionConfiguration.DestinationFieldControl;
            string         destinationFilterName   = this.currentSectionConfiguration.DestinationFilterName;
            UPConfigFilter companyRelatedFilter    = null;

            if (this.companyRelated)
            {
                string companyFilterName = $"{destinationFieldControl.InfoAreaId}.CompanyRelated";
                companyRelatedFilter = configStore.FilterByName(companyFilterName);
            }

            UPContainerMetaInfo container = new UPContainerMetaInfo(destinationFieldControl);

            container.SetLinkRecordIdentification(this.rootRecordIdentification);
            List <UPConfigFilter> appliedFilters = new List <UPConfigFilter>();
            UPConfigFilter        filter         = configStore.FilterByName(destinationFilterName);

            if (filter != null)
            {
                filter = filter.FilterByApplyingReplacements(UPConditionValueReplacement.ReplacementsFromValueParameterDictionary(fieldValueDictionary));
                container.ApplyFilter(filter);
                appliedFilters.Add(filter);
            }

            if (companyRelatedFilter != null && this.currentSectionConfiguration.SourceFieldControl != null)
            {
                companyRelatedFilter = companyRelatedFilter.FilterByApplyingReplacements(new UPConditionValueReplacement(fieldValueDictionary));
                container.ApplyFilter(companyRelatedFilter);
                appliedFilters.Add(companyRelatedFilter);
            }

            this.objectivesForRecordOperation = null;
            this.rightFilterOperation         = null;
            this.filterLoaded = true;
            if (this.RightsFilter != null && this.filterItemsResult == null)
            {
                this.filterLoaded = false;
            }

            if (this.currentSectionConfiguration.ExecuteActionFilter != null)
            {
                this.currentSectionConfiguration.ExecuteActionFilter = this.currentSectionConfiguration.ExecuteActionFilter.FilterByApplyingValueDictionaryDefaults(fieldValueDictionary, true);
                if (this.currentSectionConfiguration.ExecuteActionFilter != null)
                {
                    this.currentSectionConfiguration.FilterBasedDecision = new UPCRMFilterBasedDecision(this.currentSectionConfiguration.ExecuteActionFilter);
                    List <UPCRMField> fields = this.currentSectionConfiguration.FilterBasedDecision.FieldDictionary.Values.ToList();
                    if (fields.Count > 0)
                    {
                        container.AddCrmFields(fields);
                    }

                    this.currentSectionConfiguration.FilterBasedDecision.UseCrmQuery(container);
                }
            }

            this.objectivesForRecordOperation = container.Find(this.RequestOption, this);
            if (this.objectivesForRecordOperation == null)
            {
                SimpleIoc.Default.GetInstance <ILogger>().LogError("Could not create operation for loading objectives.");
                this.FailWithError(new Exception("ConnectionOfflineError"));
            }

            if (this.RightsFilter != null && this.filterItemsResult == null)
            {
                UPContainerMetaInfo clonedContainer = new UPContainerMetaInfo(new List <UPCRMField>(), destinationFieldControl.InfoAreaId);
                clonedContainer.SetLinkRecordIdentification(this.rootRecordIdentification);
                clonedContainer.ApplyFilter(this.RightsFilter);
                foreach (UPConfigFilter filter1 in appliedFilters)
                {
                    clonedContainer.ApplyFilter(filter1);
                }

                this.rightFilterOperation = clonedContainer.Find(this.RequestOption, this);
                if (this.rightFilterOperation == null)
                {
                    SimpleIoc.Default.GetInstance <ILogger>().LogError("Could not create operation for filtering objectives.");
                    this.FailWithError(new Exception("ConnectionOfflineError"));
                }
            }
        }
        /// <summary>
        /// The crm query for value.
        /// </summary>
        /// <param name="searchValue">
        /// The search value.
        /// </param>
        /// <param name="filters">
        /// The filters.
        /// </param>
        /// <param name="fullTextSearch">
        /// The full text search.
        /// </param>
        /// <returns>
        /// The <see cref="UPContainerMetaInfo"/>.
        /// </returns>
        public UPContainerMetaInfo CrmQueryForValue(
            string searchValue,
            List <UPConfigFilter> filters,
            bool fullTextSearch)
        {
            if (this.CombinedControl == null)
            {
                return(null);
            }

            if (this.SearchCRMFields == null && this.MultiSearchCRMFields == null &&
                this.SearchFieldControl?.Tabs?.Count > 0)
            {
                int tabCount = this.SearchFieldControl.Tabs.Count;

                List <UPCRMField> fieldArray      = null;
                List <UPCRMField> multiFieldArray = null;

                for (int i = 0; i < tabCount; i++)
                {
                    FieldControlTab tab = this.SearchFieldControl.TabAtIndex(i);
                    if (tab.Fields == null || tab.Fields.Count == 0)
                    {
                        continue;
                    }

                    if (string.Compare(tab.Type, @"MULTI", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        UPCRMField multiField = tab.FieldAtIndex(0).Field;

                        if (multiFieldArray == null)
                        {
                            multiFieldArray = new List <UPCRMField>();
                        }

                        multiFieldArray.Add(multiField);
                    }
                    else
                    {
                        if (fieldArray == null)
                        {
                            fieldArray = new List <UPCRMField>();
                        }

                        fieldArray.AddRange(tab.AllCRMFields());
                    }
                }

                this.SearchCRMFields      = fieldArray;
                this.MultiSearchCRMFields = multiFieldArray;
            }

            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            UPContainerMetaInfo     container   = new UPContainerMetaInfo(this.CombinedControl);

            if (!string.IsNullOrEmpty(this.DetailActionSwitchFilterName))
            {
                this.DetailActionSwitchFilter = ConfigurationUnitStore.DefaultStore.FilterByName(this.DetailActionSwitchFilterName);

                if (this.DetailActionSwitchFilter != null)
                {
                    this.DetailActionSwitchFilter =
                        this.DetailActionSwitchFilter.FilterByApplyingValueDictionaryDefaults(
                            this.FilterParameter,
                            true);
                }

                if (this.DetailActionSwitchFilter != null)
                {
                    this.FilterBasedDecision = new UPCRMFilterBasedDecision(this.DetailActionSwitchFilter);
                }
            }

            container.ReplaceCaseSensitiveCharacters = this.ReplaceCaseSensitiveCharacters;

            List <UPCRMField> additionalFields = null;

            if (this.ExpandSettings != null)
            {
                Dictionary <string, UPCRMField> alternateExpandFields =
                    this.ExpandSettings.FieldsForAlternateExpands(true);
                List <UPCRMField> _additionalFields = this.AdditionalOutputFields != null
                                                         ? new List <UPCRMField>(this.AdditionalOutputFields)
                                                         : new List <UPCRMField>();

                if (alternateExpandFields != null)
                {
                    _additionalFields.AddRange(alternateExpandFields.Values.Where(field => container.ContainsField(field) == null));
                }

                additionalFields = _additionalFields;
            }
            else if (this.AdditionalOutputFields?.Count > 0)
            {
                additionalFields = this.AdditionalOutputFields;
            }

            if (additionalFields != null && additionalFields.Count > 0)
            {
                container.AddCrmFields(additionalFields);
            }

            var checkFilterFields = this.FilterBasedDecision?.FieldDictionary.Values.Select(x => x).ToList();

            if (checkFilterFields?.Count > 0)
            {
                container.AddCrmFields(checkFilterFields);
                this.FilterBasedDecision.UseCrmQuery(container);
            }

            if (this.ExpandSettings != null)
            {
                this.ExpandChecker = this.ExpandSettings.ExpandCheckerForCrmQuery(container);
            }

            if (!string.IsNullOrEmpty(this.LinkRecordIdentification))
            {
                container.SetLinkRecordIdentification(this.LinkRecordIdentification);
            }

            if (this.SearchFieldControl != null)
            {
                container.SetSearchConditionsFor(
                    searchValue,
                    this.SearchCRMFields,
                    this.MultiSearchCRMFields,
                    fullTextSearch);
            }
            else if (this.QuickSearchEntries != null)
            {
                if (!string.IsNullOrEmpty(searchValue))
                {
                    List <UPCRMField> crmFields = this.QuickSearchEntries.Select(entry => entry.CrmField).ToList();

                    container.SetSearchConditionsFor(searchValue, crmFields, fullTextSearch);
                }
            }

            if (!string.IsNullOrEmpty(this.SearchConfiguration?.FilterName))
            {
                UPConfigFilter filter = configStore.FilterByName(this.SearchConfiguration.FilterName);

                if (filter != null)
                {
                    filter = filter.FilterByApplyingDefaultReplacements();
                    filter = filter.FilterByApplyingValueDictionary(this.FilterParameter);
                    container.ApplyFilter(filter);
                }
            }

            if (this.FilterObject != null)
            {
                container.ApplyFilter(this.FilterObject);
            }
            else if (!string.IsNullOrEmpty(this.FilterName))
            {
                UPConfigFilter filter = configStore.FilterByName(this.FilterName);
                if (filter != null)
                {
                    filter = filter.FilterByApplyingDefaultReplacements();
                    filter = filter.FilterByApplyingValueDictionary(this.FilterParameter);
                    container.ApplyFilter(filter);
                }
            }

            if (filters != null)
            {
                foreach (UPConfigFilter filter in filters)
                {
                    if (this.FilterParameter != null)
                    {
                        container.ApplyFilterWithReplacementDictionary(filter, this.FilterParameter);
                    }
                    else
                    {
                        container.ApplyFilter(filter);
                    }
                }
            }

            return(container);
        }
Пример #26
0
        private void Search(object _docPage)
        {
            UPMDocumentPage docPage = (UPMDocumentPage)_docPage;

            this.currentSearchOperation?.Cancel();
            if (this.preparedSearch == null)
            {
                this.preparedSearch = new UPSearchPageModelControllerPreparedSearch(this.InfoAreaId, this.ConfigName, this.filterName);
            }

            if (this.preparedSearch.CombinedControl == null)
            {
                this.SearchOperationDidFinishWithResult(null, null);
                return;     // dont crash but do nothing if no list exists
            }

            IConfigurationUnitStore configStore   = ConfigurationUnitStore.DefaultStore;
            FieldControl            searchControl = configStore.FieldControlByNameFromGroup("Search", this.preparedSearch.SearchConfiguration.FieldGroupName);

            if (searchControl != null)
            {
                string searchLabel = string.Empty;
                int    count       = searchControl.NumberOfFields;
                for (int i = 0; i < count; i++)
                {
                    searchLabel = i == 0 ? searchControl.FieldAtIndex(i).Label : $"{searchLabel} | {searchControl.FieldAtIndex(i).Label}";
                }

                docPage.SearchPlaceholder = searchLabel;
            }

            if (string.IsNullOrEmpty(docPage.SearchText))
            {
                int range = this.ViewReference.ContextValueForKey("SearchOptions")?.IndexOf("NoEmptySearch") ?? 0;
                if (range >= 0)
                {
                    this.SearchOperationDidFinishWithResult(null, null);
                    return;
                }
            }

            List <UPConfigFilter> configFilters     = UPMFilter.ActiveFiltersForFilters(docPage.AvailableFilters);
            UPContainerMetaInfo   containerMetaInfo = this.preparedSearch.CrmQueryForValue(docPage.SearchText, configFilters, this.fullTextSearch);

            if (this.recordIdentification.IsRecordIdentification())
            {
                containerMetaInfo.SetLinkRecordIdentification(this.recordIdentification, 126, 127);
            }

            if (docPage.SearchType == SearchPageSearchType.OfflineSearch)
            {
                this.currentSearchOperation = containerMetaInfo.Find(UPRequestOption.Offline, this);
            }
            else if (docPage.SearchType == SearchPageSearchType.OnlineSearch)
            {
                this.currentSearchOperation = containerMetaInfo.Find(this);
            }
            else
            {
                SimpleIoc.Default.GetInstance <ILogger>().LogError($"Unknown search type: {docPage.SearchType}");
            }
        }
        /// <summary>
        /// Updates the page with result.
        /// </summary>
        /// <param name="result">
        /// The result.
        /// </param>
        public void UpdatePageWithResult(UPCRMResult result)
        {
            if (result == null)
            {
                return;
            }

            var oldPage = this.Page;
            var newPage = (MDetailPage)this.InstantiatePage();

            newPage.LabelText = oldPage.LabelText;
            newPage.Invalid   = false;
            newPage.Status    = null;
            if (result.RowCount == 0)
            {
                if (this.RequestOption == UPRequestOption.BestAvailable)
                {
                    var containerMetaInfo = new UPContainerMetaInfo(this.detailsControl)
                    {
                        ReplaceCaseSensitiveCharacters =
                            ConfigurationUnitStore.DefaultStore.ConfigValueIsSet(
                                "Search.ReplaceCaseSensitiveCharacters")
                    };

                    if (string.IsNullOrWhiteSpace(this.LinkRecordIdentification))
                    {
                        result = containerMetaInfo.ReadRecord(this.infoAreaId.InfoAreaIdRecordId(this.recordId));
                    }
                    else
                    {
                        containerMetaInfo.SetLinkRecordIdentification(this.LinkRecordIdentification, this.LinkId);
                        result = containerMetaInfo.Find();
                    }

                    if (result.RowCount == 0)
                    {
                        var errorStatus = UPMErrorStatus.ErrorStatusWithMessageDetails("Loading error", null);
                        newPage.Status       = errorStatus;
                        newPage.Invalid      = true;
                        this.TopLevelElement = newPage;
                        this.InformAboutDidFailTopLevelElement(this.Page);
                        return;
                    }
                }
                else
                {
                    var errorStatus = UPMErrorStatus.ErrorStatusWithMessageDetails("Loading error", null);
                    newPage.Status       = errorStatus;
                    newPage.Invalid      = true;
                    this.TopLevelElement = newPage;
                    this.InformAboutDidFailTopLevelElement(this.Page);
                    return;
                }
            }

            var resultRow = result.ResultRowAtIndex(0) as UPCRMResultRow;

            this.FillPageWithResultRow(
                newPage,
                resultRow,
                resultRow.IsServerResponse ? UPRequestOption.Online : UPRequestOption.Offline);
            this.ApplySubTitleFromResultRow(resultRow);
            this.TopLevelElement = newPage;
            this.InformAboutDidChangeTopLevelElement(oldPage, newPage, null, null);
        }