예제 #1
0
        private void HandleOwnerResult(UPCRMResult result)
        {
            int count = result.RowCount;

            if (count > 0)
            {
                List <UPSEListingOwner> relatedOwnersForCurrentOwner = new List <UPSEListingOwner>();
                for (int i = 0; i < count; i++)
                {
                    UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i);
                    string         recordIdentification = row.RecordIdentificationAtIndex(1);
                    if (string.IsNullOrEmpty(recordIdentification))
                    {
                        continue;
                    }

                    UPSEListingOwner relatedOwner = this.listingOwners.ValueOrDefault(row.RecordIdentificationAtIndex(1));
                    if (relatedOwner == null)
                    {
                        relatedOwner = new UPSEListingOwner((UPCRMResultRow)result.ResultRowAtIndex(i), 1, this.ListingOwnerMapping, this);
                        this.loadQueue.Add(relatedOwner);
                        this.listingOwners.SetObjectForKey(relatedOwner, relatedOwner.RecordIdentification);
                    }

                    relatedOwnersForCurrentOwner.Add(relatedOwner);
                }

                this.currentLoadedOwner.RelatedOwners = relatedOwnersForCurrentOwner;
            }

            this.LoadNextItemFromQueue();
        }
예제 #2
0
        /// <summary>
        /// Searches the operation did finish with result.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="searchResult">The search result.</param>
        public void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult searchResult)
        {
            if (operation == this.rightFilterOperation)
            {
                this.filterItems = null;
                if (searchResult?.RowCount > 0)
                {
                    Dictionary <string, UPCRMResultRow> tempFilterItems = new Dictionary <string, UPCRMResultRow>();
                    for (int i = 0; i < searchResult.RowCount; i++)
                    {
                        UPCRMResultRow resultRow = (UPCRMResultRow)searchResult.ResultRowAtIndex(i);
                        tempFilterItems[resultRow.RootRecordIdentification] = resultRow;
                    }

                    this.filterItems = tempFilterItems;
                }
                else
                {
                    this.filterItems = new Dictionary <string, UPCRMResultRow>();
                }

                this.filterItemsResult    = searchResult;
                this.filterLoaded         = true;
                this.rightFilterOperation = null;
            }
            else if (operation == this.objectivesForRecordOperation)
            {
                this.allItems = null;
                if (searchResult != null && searchResult.RowCount > 0)
                {
                    List <UPCRMResultRow> itemArray = new List <UPCRMResultRow>();
                    for (int i = 0; i < searchResult.RowCount; i++)
                    {
                        UPCRMResultRow resultRow = (UPCRMResultRow)searchResult.ResultRowAtIndex(i);
                        itemArray.Add(resultRow);
                    }

                    // load document for each item
                    this.currentItemDocumentIndex = 0;
                    this.itemDocumentsToLoad      = searchResult.RowCount;
                    this.allItems       = new List <UPCRMResultRow>(itemArray);
                    this.allItemsResult = searchResult;
                }

                this.objectivesForRecordOperation = null;
            }

            // everthing loaded .... continue building the groups
            if (this.filterLoaded && this.rightFilterOperation == null && this.objectivesForRecordOperation == null)
            {
                this.BuildGroupWithConfigurationItemsUpdateableItems(this.groupConfigurations[this.currentGroupIndex], this.allItems, this.filterItems);
            }
        }
예제 #3
0
        /// <summary>
        /// Searches the operation did finish with result.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="result">The result.</param>
        public void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            switch (this.loadStep)
            {
            case 11:
                if (result?.RowCount > 1)
                {
                    this.TheDelegate.SurveyDidFailWithError(this, new Exception("SourceCopyFields could not be loaded"));
                    return;
                }

                if (result == null || result?.RowCount == 0)
                {
                    this.crmQuery = null;
                    this.TrySourceCopyFieldGroupOfflineWithRecordLink();
                    return;
                }

                this.crmQuery = null;
                this.SourceCopyFieldGroupLoaded((UPCRMResultRow)result.ResultRowAtIndex(0));
                return;

            case 1:
                if (result?.RowCount != 1)
                {
                    this.TheDelegate.SurveyDidFailWithError(this, new Exception("SourceCopyFields could not be loaded"));
                    return;
                }

                this.crmQuery = null;
                this.SourceCopyFieldGroupLoaded((UPCRMResultRow)result.ResultRowAtIndex(0));
                return;

            case 2:
                this.SurveyLoaded(result.RowCount == 0 ? null : (UPCRMResultRow)result.ResultRowAtIndex(0));
                return;

            case 3:
                this.SurveyAnswersLoaded(result);
                return;

            case 4:
                this.ForeignFieldsLoaded(result.RowCount == 0 ? null : (UPCRMResultRow)result.ResultRowAtIndex(0));
                return;

            default:
                break;
            }
        }
        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);
        }
예제 #5
0
        private UPMContactTimesGroup FillGroupVrianteWithoutType(UPCRMResult result)
        {
            var functionNames = this.fieldControl.FunctionNames();

            this.contactTimesGroup = this.EmptyGroup();
            for (int row = 0; row < result.RowCount; row++)
            {
                var resultRow = result.ResultRowAtIndex(row) as UPCRMResultRow;
                if (functionNames.Keys.Contains("OPENFROM") && functionNames.Keys.Contains("OPENTO"))
                {
                    this.FillTimesVariantWithoutType(resultRow, "0", "OPEN");
                }

                if (functionNames.Keys.Contains("VISITFROM") && functionNames.Keys.Contains("VISITTO"))
                {
                    this.FillTimesVariantWithoutType(resultRow, "1", "VISIT");
                }

                if (functionNames.Keys.Contains("PHONEFROM") && functionNames.Keys.Contains("PHONETO"))
                {
                    this.FillTimesVariantWithoutType(resultRow, "2", "PHONE");
                }
            }

            return(this.contactTimesGroup);
        }
예제 #6
0
        private UPMContactTimesGroup FillGroupVrianteWithoutType(UPCRMResult result)
        {
            this.contactTimesGroup = this.EmptyGroup();
            var functionNames = this.FieldControl.FunctionNames();

            for (int row = 0; row < result.RowCount; row++)
            {
                var resultRow = result.ResultRowAtIndex(row) as UPCRMResultRow;
                if (functionNames.Keys.Contains("OPENFROM") && functionNames.Keys.Contains("OPENTO"))
                {
                    this.contactTimesGroup.AddTitleForTimeType(LocalizedString.TextOpeningTimes, "0");
                    this.FillTimesVrianteWithoutTypeFromResultRowTimeTypePrefix(resultRow, "0", "OPEN");
                }

                if (functionNames.Keys.Contains("VISITFROM") && functionNames.Keys.Contains("VISITTO"))
                {
                    this.contactTimesGroup.AddTitleForTimeType(LocalizedString.TextVisitTimes, "1");
                    this.FillTimesVrianteWithoutTypeFromResultRowTimeTypePrefix(resultRow, "1", "VISIT");
                }

                if (functionNames.Keys.Contains("PHONEFROM") && functionNames.Keys.Contains("PHONETO"))
                {
                    this.contactTimesGroup.AddTitleForTimeType(LocalizedString.TextPhoneTimes, "2");
                    this.FillTimesVrianteWithoutTypeFromResultRowTimeTypePrefix(resultRow, "2", "PHONE");
                }
            }

            return(this.contactTimesGroup);
        }
        private void ApplyQuotaResult(UPCRMResult result)
        {
            int count = result.RowCount;

            this.quotaDictionary = new Dictionary <string, UPSEQuota>();
            for (int i = 0; i < count; i++)
            {
                UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i);
                Dictionary <string, object> dict = row.ValuesWithFunctions();
                string itemNumber = dict.ValueOrDefault(this.ItemNumberFunctionName) as string;
                if (string.IsNullOrEmpty(itemNumber))
                {
                    continue;
                }

                UPSEQuota quota = this.quotaDictionary.ValueOrDefault(itemNumber);
                if (quota == null)
                {
                    quota = new UPSEQuota(itemNumber, this);
                    this.quotaDictionary.SetObjectForKey(quota, itemNumber);
                }

                quota.ApplyRecordIdentificationValues(row.RootRecordIdentification, dict);
            }

            this.Finished();
        }
예제 #8
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);
        }
예제 #9
0
        private void SurveyAnswersLoaded(UPCRMResult result)
        {
            int count = result.RowCount;

            for (int i = 0; i < count; i++)
            {
                UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i);
                Dictionary <string, object> valuesWithFunction = row.ValuesWithFunctions();
                string questionKey = valuesWithFunction.ValueOrDefault(Constants.QuestionnaireQuestionNumber) as string;
                UPQuestionnaireQuestion question = this.Questionnaire?.QuestionForId(questionKey);
                if (question == null)
                {
                    continue;
                }

                UPSurveyAnswer answer = null;
                if (question.Multiple)
                {
                    answer = this.surveyAnswers.ValueOrDefault(questionKey);
                }

                if (answer == null)
                {
                    answer = new UPSurveyAnswer(row.RootRecordIdentification, valuesWithFunction, question, this);
                    this.surveyAnswers[questionKey] = answer;
                }
                else
                {
                    answer.AddAnswer(valuesWithFunction, row.RootRecordIdentification);
                }
            }

            this.crmQuery = null;
            this.LoadFinished();
        }
        /// <summary>
        /// Filters for configuration filter.
        /// </summary>
        /// <param name="configFilter">The configuration filter.</param>
        /// <param name="searchAndListName">Name of the search and list.</param>
        /// <param name="filterParameters">The filter parameters.</param>
        /// <param name="singleSelect">if set to <c>true</c> [single select].</param>
        /// /// <returns>Filter</returns>
        public static UPMFilter FilterForConfigFilter(UPConfigFilter configFilter, string searchAndListName, Dictionary <string, object> filterParameters, bool singleSelect)
        {
            if (string.IsNullOrEmpty(searchAndListName))
            {
                return(null);
            }

            IConfigurationUnitStore configStore   = ConfigurationUnitStore.DefaultStore;
            SearchAndList           searchAndList = configStore.SearchAndListByName(searchAndListName);

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

            FieldControl listControl = configStore.FieldControlByNameFromGroup("List", searchAndList.FieldGroupName);

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

            UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(searchAndListName, filterParameters);

            UPCRMResult result = crmQuery.Find();
            int         count  = result.RowCount;

            if (count == 0)
            {
                return(null);
            }

            UPCRMListFormatter                  listFormatter = new UPCRMListFormatter(listControl.TabAtIndex(0));
            StringIdentifier                    identifier    = StringIdentifier.IdentifierWithStringId("SelectFilter");
            UPMSelectCatalogFilter              filter        = new UPMSelectCatalogFilter(identifier);
            Dictionary <string, string>         dict          = new Dictionary <string, string>(count);
            Dictionary <string, UPCRMResultRow> rowDict       = new Dictionary <string, UPCRMResultRow>(count);

            for (int i = 0; i < count; i++)
            {
                UPCRMResultRow row        = (UPCRMResultRow)result.ResultRowAtIndex(i);
                string         fieldValue = listFormatter.StringFromRowForPosition(row, 0);
                dict[row.RootRecordIdentification]    = fieldValue;
                rowDict[row.RootRecordIdentification] = row;
            }

            filter.CrmResult             = result;
            filter.FilterParameters      = filterParameters;
            filter.ResultRowDictionary   = rowDict;
            filter.ExplicitCatalogValues = dict;
            filter.ParameterName         = "Select";
            filter.Name = configFilter.UnitName;

            filter.DisplayName = !string.IsNullOrEmpty(configFilter.DisplayName) ? configFilter.DisplayName : configFilter.UnitName;

            filter.SingleSelect = singleSelect;
            return(filter);
        }
        /// <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);
        }
예제 #12
0
        private void FillPageWithResult(UPCRMResult result)
        {
            this.vistedNodes      = new Dictionary <IIdentifier, UPMCoINode>();
            this.nodeIdConfigDict = new Dictionary <IIdentifier, UPConfigTreeViewTable>();

            // Root Node Query
            if (result.RowCount == 1)
            {
                UPCRMResultRow row      = (UPCRMResultRow)result.ResultRowAtIndex(0);
                UPMCoINode     rootNode = CoITreeNodeLoader.CreateNodeFromResultRow(row, 0, this.expandChecker, null, null);
                this.vistedNodes[rootNode.Identifier]      = rootNode;
                this.nodeIdConfigDict[rootNode.Identifier] = this.rootTreeNode.RootNode;

                // Only root configured
                if (this.rootTreeNode.RootNode.ChildNodes.Count == 0)
                {
                    UPMCircleOfInfluencePage newPage = this.CreatePageInstance();
                    newPage.RootNode       = rootNode;
                    newPage.Invalid        = false;
                    newPage.ConfigProvider = ((UPMCircleOfInfluencePage)this.Page).ConfigProvider;
                    UPMCircleOfInfluencePage oldPage = (UPMCircleOfInfluencePage)this.Page;
                    this.TopLevelElement = newPage;
                    this.InformAboutDidChangeTopLevelElement(oldPage, newPage, null, null);
                }

                foreach (UPConfigTreeViewTable childTree in this.rootTreeNode.RootNode.ChildNodes)
                {
                    CoITreeNodeLoader nodeLoader = new CoITreeNodeLoader(rootNode, childTree, this.ViewReference, 0, this.vistedNodes, this.nodeIdConfigDict, this.recordIdentifierInfoAreaConfigMapping);
                    nodeLoader.TheDelegate = this;
                    nodeLoader.Mode        = CoINodeLoaderMode.InitialLoad;
                    this.pendingNodeLoader.Add(nodeLoader);
                    this.pendingNodeLoaderCount++;
                }
                // TODO: This is buggy and will be implemented in CRM-5621

                /*
                 * foreach (CoITreeNodeLoader _loader in this.pendingNodeLoader)
                 * {
                 *  _loader.LoadNodeSubNodes();
                 * }
                 */
            }
            else
            {
                // Request Mode Offline and jump To Online Node
                if (result.RowCount == 0 && this.RequestOption == UPRequestOption.Offline)
                {
                    // Offline Configured and Online Record
                    UPMCircleOfInfluencePage newPage = this.CreatePageInstance();
                    newPage.Status = UPMMessageStatus.MessageStatusWithMessageDetails(string.Empty, LocalizedString.TextOfflineNotAvailable);
                    UPMCircleOfInfluencePage oldPage = (UPMCircleOfInfluencePage)this.Page;
                    this.TopLevelElement = newPage;
                    this.InformAboutDidChangeTopLevelElement(oldPage, newPage, null, null);
                }
            }
        }
        private void HandleResult(UPCRMResult result)
        {
            this.currencyDictionary = new Dictionary <int, object>();
            if (result != null && result.RowCount > 0)
            {
                UPConfigFieldControlField currencyField = null, baseCurrencyField = null, exchangeRateField = null, baseCurrency2Field = null, exchangeRate2Field = null;
                foreach (FieldControlTab tab in this.fieldControl.Tabs)
                {
                    foreach (UPConfigFieldControlField field in tab.Fields)
                    {
                        if (field.Function == "Currency")
                        {
                            currencyField = field;
                        }
                        else if (field.Function == "BaseCurrency")
                        {
                            baseCurrencyField = field;
                        }
                        else if (field.Function == "ExchangeRate")
                        {
                            exchangeRateField = field;
                        }
                        else if (field.Function == "BaseCurrency2")
                        {
                            baseCurrency2Field = field;
                        }
                        else if (field.Function == "ExchangeRate2")
                        {
                            exchangeRate2Field = field;
                        }
                    }
                }

                if (currencyField != null && baseCurrencyField != null && exchangeRateField != null && result.RowCount > 0)
                {
                    int i, count = result.RowCount;
                    for (i = 0; i < count; i++)
                    {
                        UPCRMResultRow row  = result.ResultRowAtIndex(i) as UPCRMResultRow;
                        int            code = row.RawValueAtIndex(currencyField.TabIndependentFieldIndex).ToInt();
                        int            baseCurrencyValue  = row.RawValueAtIndex(baseCurrencyField.TabIndependentFieldIndex).ToInt();
                        double         exchangeRate       = row.RawValueAtIndex(exchangeRateField.TabIndependentFieldIndex).ToDouble();
                        double         exchangeRate2      = 0;
                        int            baseCurrency2Value = 0;
                        if (baseCurrency2Field != null && exchangeRate2Field != null)
                        {
                            baseCurrency2Value = row.RawValueAtIndex(baseCurrency2Field.TabIndependentFieldIndex).ToInt();
                            exchangeRate2      = row.RawValueAtIndex(exchangeRate2Field.TabIndependentFieldIndex).ToDouble();
                        }

                        this.AddCurrency(new Currency(code, baseCurrencyValue, exchangeRate, baseCurrency2Value, exchangeRate2));
                    }
                }
            }
        }
예제 #14
0
        /// <summary>
        /// Applies the result.
        /// </summary>
        /// <param name="result">
        /// The result.
        /// </param>
        public void ApplyResult(UPCRMResult result)
        {
            if (!result.IsServerResult)
            {
                return;
            }

            var resultRowCount = result.RowCount;

            if (resultRowCount == 0)
            {
                return;
            }

            var dataStore           = UPCRMDataStore.DefaultStore;
            var resultInfoAreaCount = result.MetaInfo.NumberOfResultInfoAreaMetaInfos();
            var mapping             = new int[resultInfoAreaCount];
            var cacheForInfoAreaMap = new UPVirtualInfoAreaCacheForInfoArea[resultInfoAreaCount];
            var count = 0;

            for (var i = 0; i < resultInfoAreaCount; i++)
            {
                var infoAreaMetaInfo = result.MetaInfo.ResultInfoAreaMetaInfoAtIndex(i);
                var tableInfo        = dataStore.TableInfoForInfoArea(infoAreaMetaInfo.InfoAreaId);
                if (tableInfo == null || !tableInfo.HasVirtualInfoAreas)
                {
                    continue;
                }

                mapping[count]             = i;
                cacheForInfoAreaMap[count] = this.CacheForInfoAreaId(tableInfo.InfoAreaId);
                ++count;
            }

            if (count == 0)
            {
                return;
            }

            for (var i = 0; i < resultRowCount; i++)
            {
                var row = result.ResultRowAtIndex(i) as UPCRMResultRow;
                if (row == null)
                {
                    continue;
                }

                for (var j = 0; j < count; j++)
                {
                    cacheForInfoAreaMap[j].AddRecordIdInfoAreaId(
                        row.RecordIdAtIndex(mapping[j]),
                        row.VirtualInfoAreaIdAtIndex(mapping[j]));
                }
            }
        }
예제 #15
0
        private bool FillGroupWithLocalDocumentsResult(UPMDocumentsGroup group, UPCRMResult result)
        {
            if (this._sendEmailFieldgroup != null)
            {
                this._linkedRecordId = this.RecordIdentification;
            }

            int count = result.RowCount;

            if (count == 0)
            {
                return(false);
            }

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

            DocumentInfoAreaManager documentInfoAreaManager;

            if (this.fieldControl.InfoAreaId == "D3" && this.TabConfig.Type.StartsWith("D1"))
            {
                documentInfoAreaManager = new DocumentInfoAreaManager(this.fieldControl.InfoAreaId, this.fieldControl, 1, null);
            }
            else
            {
                documentInfoAreaManager = new DocumentInfoAreaManager(this.fieldControl.InfoAreaId, this.fieldControl, null);
            }

            for (int i = 0; i < count; i++)
            {
                UPCRMResultRow resultRow    = (UPCRMResultRow)result.ResultRowAtIndex(i);
                DocumentData   documentData = documentInfoAreaManager.DocumentDataForResultRow(resultRow);
                UPMDocument    document     = new UPMDocument(documentData);
                if (this._sendEmailFieldgroup != null)
                {
                    document.LinkedRecordId  = this._linkedRecordId;
                    document.EmailFieldgroup = this._sendEmailFieldgroup;
                }

                if (this.IsDocumentIncludedInGroup(document, group))
                {
                    group.AddField(document);
                }
            }

            if (group.Fields.Count == 0)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Results the section for search result.
        /// </summary>
        /// <param name="preparedSearch">The prepared search.</param>
        /// <param name="result">The result.</param>
        /// <returns></returns>
        public virtual UPMResultSection ResultSectionForSearchResult(UPSearchPageModelControllerPreparedSearch preparedSearch, UPCRMResult result)
        {
            var configStore   = ConfigurationUnitStore.DefaultStore;
            var resultContext = new UPCoreMappingResultContext(result, preparedSearch.CombinedControl, preparedSearch.ListFieldControl.NumberOfFields);

            this.SectionContexts.SetObjectForKey(resultContext, preparedSearch.InfoAreaId);
            var resultSection  = new UPMResultSection(StringIdentifier.IdentifierWithStringId($"Search_{preparedSearch.InfoAreaId}"));
            var infoAreaConfig = configStore.InfoAreaConfigById(preparedSearch.InfoAreaId);

            if (infoAreaConfig != null)
            {
                var colorKey = infoAreaConfig.ColorKey;
                if (!string.IsNullOrEmpty(colorKey))
                {
                    resultSection.BarColor = AureaColor.ColorWithString(colorKey);
                }

                var imageName = infoAreaConfig.ImageName;
                if (!string.IsNullOrEmpty(imageName))
                {
                    var fileResource = configStore.ResourceByName(imageName);
                    if (fileResource != null)
                    {
                        resultSection.GlobalSearchIconName = fileResource.FileName;
                    }
                }
            }

            resultSection.SectionField = new UPMField(StringIdentifier.IdentifierWithStringId("SectionLabel"));
            var sectionName = infoAreaConfig?.PluralName;

            if (string.IsNullOrEmpty(sectionName))
            {
                var tableInfo = UPCRMDataStore.DefaultStore.TableInfoForInfoArea(preparedSearch.InfoAreaId);
                sectionName = tableInfo != null ? tableInfo.Label : preparedSearch.InfoAreaId;
            }

            resultSection.SectionField.FieldValue = sectionName;
            var count = result.RowCount;

            for (var j = 0; j < count; j++)
            {
                var dataRow    = result.ResultRowAtIndex(j) as UPCRMResultRow;
                var identifier = new RecordIdentifier(preparedSearch.InfoAreaId, dataRow.RecordIdAtIndex(0));
                var resultRow  = new UPMResultRow(identifier);
                resultContext.RowDictionary.Add(resultRow.Key, new UPCoreMappingResultRowContext(dataRow, resultContext));
                resultContext.ExpandMapper = preparedSearch.ExpandSettings;
                resultRow.Invalid          = true;
                resultRow.DataValid        = true;
                resultSection.AddResultRow(resultRow);
            }

            return(resultSection);
        }
예제 #17
0
        private UPMContactTimesGroup FillGroupVrianteWithType(UPCRMResult result)
        {
            this.contactTimesGroup = this.EmptyGroup();
            for (int row = 0; row < result.RowCount; row++)
            {
                var resultRow           = (UPCRMResultRow)result.ResultRowAtIndex(row);
                var valuesWithFunctions = resultRow.ValuesWithFunctions();
                this.FillTimesVrianteWithTypeFromResultRowTimeType(resultRow, valuesWithFunctions.ValueOrDefault("TYPE") as string);
            }

            return(this.contactTimesGroup);
        }
 private void FillPageWithResult(UPCRMResult result)
 {
     this.vistedNodes = new Dictionary <IIdentifier, UPMCoINode>();
     if (result.RowCount == 1)
     {
         UPCRMResultRow row      = (UPCRMResultRow)result.ResultRowAtIndex(0);
         UPMCoINode     rootNode = CoINodeLoader.CreateRootNodeFromResultRow(row, this.RootRecordIdentification, 0, this.expandChecker);
         this.vistedNodes[rootNode.Identifier] = rootNode;
         if (this.MaxDepth > 0)
         {
             this.currentNodeLoader             = new CoINodeLoader(rootNode, this.ViewReference, 0, this.MaxDepth, this.vistedNodes);
             this.currentNodeLoader.TheDelegate = this;
             this.currentNodeLoader.Mode        = CoINodeLoaderMode.InitialLoad;
             this.currentNodeLoader.LoadNodeSubNodes();
         }
         else
         {
             // Finished loading
             UPMCircleOfInfluencePage newPage = this.CreatePageInstance();
             newPage.RootNode       = rootNode;
             newPage.Invalid        = false;
             newPage.ConfigProvider = ((UPMCircleOfInfluencePage)this.Page).ConfigProvider;
             UPMCircleOfInfluencePage oldPage = (UPMCircleOfInfluencePage)this.Page;
             this.TopLevelElement = newPage;
             if (!oldPage.Invalid && oldPage.RootNode.Invalid)
             {
                 // return from edir
                 newPage.RefreshedNode = newPage.RootNode;
                 this.InformAboutDidChangeTopLevelElement(oldPage, newPage, new List <IIdentifier> {
                     oldPage.RootNode.Identifier
                 }, null);
             }
             else
             {
                 this.InformAboutDidChangeTopLevelElement(oldPage, newPage, null, null);
             }
         }
     }
     else
     {
         // Request Mode Offline and jump To Online Node
         if (result.RowCount == 0 && this.RequestOption == UPRequestOption.Offline)
         {
             // Offline Configured and Online Record
             UPMCircleOfInfluencePage newPage = this.CreatePageInstance();
             newPage.Status = UPMMessageStatus.MessageStatusWithMessageDetails(string.Empty, LocalizedString.TextOfflineNotAvailable);
             UPMCircleOfInfluencePage oldPage = (UPMCircleOfInfluencePage)this.Page;
             this.TopLevelElement = newPage;
             this.InformAboutDidChangeTopLevelElement(oldPage, newPage, null, null);
         }
     }
 }
        /// <summary>
        /// Searches the operation did finish with result.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="result">The result.</param>
        public void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            IConfigurationUnitStore configStore   = ConfigurationUnitStore.DefaultStore;
            SearchAndList           searchAndList = configStore.SearchAndListByName(this.searchAndListConfigurationName);

            this.detailActionViewReference = this.DefaultActionForSearchAndList(searchAndList).ViewReference;
            if (result.RowCount > 0)
            {
                this.detailActionRecordIdentifier = result.ResultRowAtIndex(0).RootRecordIdentification;
            }

            this.Delegate.GroupModelControllerFinished(this);
        }
        /// <summary>
        /// Listingses from result.
        /// </summary>
        /// <param name="result">The result.</param>
        public void ListingsFromResult(UPCRMResult result)
        {
            List <UPSEListing> listingArray = new List <UPSEListing>();
            int count = result.RowCount;

            for (int i = 0; i < count; i++)
            {
                UPCRMResultRow row  = (UPCRMResultRow)result.ResultRowAtIndex(i);
                UPSEListing    item = new UPSEListing(row, this.ListingController.ListingMapping, this);
                listingArray.Add(item);
            }

            this.Listings = listingArray;
        }
예제 #21
0
        private UPMContactTimesGroup FillGroupVariantWithType(UPCRMResult result)
        {
            this.contactTimesGroup = this.EmptyGroup();
            var functionNames = this.fieldControl.FunctionNames();

            for (int row = 0; row < result.RowCount; row++)
            {
                UPCRMResultRow resultRow           = result.ResultRowAtIndex(row) as UPCRMResultRow;
                var            valuesWithFunctions = resultRow.ValuesWithFunctions();
                this.FillTimesVariantWithType(resultRow, valuesWithFunctions.ValueOrDefault("TYPE") as string);
            }

            return(this.contactTimesGroup);
        }
        /// <summary>
        /// The search operation did finish with result.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        /// <param name="result">
        /// The result.
        /// </param>
        public void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            if (result?.RowCount > 0)
            {
                UPCRMResultRow row = result.ResultRowAtIndex(0) as UPCRMResultRow;
                this.targetExpand = this.rootExpand.ExpandForResultRow(row);
            }
            else
            {
                this.targetExpand = this.rootExpand;
            }

            this.theDelegate?.AlternateExpandCheckerDidFinishWithResult(this, this.targetExpand);
        }
예제 #23
0
        /// <summary>
        /// Searches the operation did finish with result.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="result">The result.</param>
        public void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            UPDetailsFieldGroupModelController groupModelController = new UPDetailsFieldGroupModelController(this.sourceFieldControl, 0, null);

            if (result.RowCount > 0)
            {
                groupModelController.GroupFromRowGroup((UPCRMResultRow)result.ResultRowAtIndex(0), this.origDetailGroup);
                var changedIdentifiers = new List <IIdentifier> {
                    this.origDetailGroup.Identifier
                };
                this.origDetailGroup.Invalid = false;
                this.searchPageModelController.InformAboutDidUpdateListOfErrors(new List <Exception>());
                this.searchPageModelController.InformAboutDidChangeTopLevelElement(this.searchPageModelController.TopLevelElement, this.searchPageModelController.TopLevelElement, changedIdentifiers, null);
            }
        }
        /// <summary>
        /// Applies the link record identification.
        /// </summary>
        /// <param name="recordIdentification">The record identification.</param>
        /// <returns></returns>
        public UPMGroup ApplyLinkRecordIdentification(string recordIdentification)
        {
            this.enableDelegate = false;
            if (this.LinkFields != null)
            {
                this.LinkReader      = new UPCRMLinkReader(recordIdentification, this.ParentLinkString, this.RequestOption, this);
                this.ControllerState = GroupModelControllerState.Pending;
                this.LinkReader.Start();
                this.enableDelegate = true;
                return(this.Group);
            }

            this.metaInfo = new UPContainerMetaInfo(this.ParentFieldControl);
            this.metaInfo.SetLinkRecordIdentification(recordIdentification, this.LinkId);
            this.metaInfo.DisableVirtualLinks           = true;
            this.ParentController.ExplicitTabIdentifier = this.TabIdentifierForRecordIdentification(recordIdentification);
            if (this.RequestOption == UPRequestOption.Offline || this.RequestOption == UPRequestOption.FastestAvailable)
            {
                UPCRMResult result = this.metaInfo.Find();
                if (result.RowCount > 0)
                {
                    this.ControllerState = GroupModelControllerState.Finished;
                    if (this.ParentController.ApplyResultRow((UPCRMResultRow)result.ResultRowAtIndex(0)) == null)
                    {
                        this.enableDelegate = true;
                    }

                    return(this.Group);
                }
            }

            this.enableDelegate = true;
            if (this.RequestOption != UPRequestOption.Offline)
            {
                this.ControllerState = GroupModelControllerState.Pending;
                Operation remoteOperation = this.metaInfo.Find(this);
                if (remoteOperation == null)
                {
                    this.ControllerState = GroupModelControllerState.Error;
                }
            }
            else
            {
                this.ControllerState = GroupModelControllerState.Empty;
            }

            return(null);
        }
예제 #25
0
        /// <inheritdoc/>
        public override UPMResultSection ResultSectionForSearchResult(UPSearchPageModelControllerPreparedSearch preparedSearch, UPCRMResult result)
        {
            UPCoreMappingResultContext resultContext = new UPCoreMappingResultContext(result, preparedSearch.CombinedControl, preparedSearch.ListFieldControl.NumberOfFields);

            this.SectionContexts.SetObjectForKey(resultContext, preparedSearch.InfoAreaId);
            bool newSection = this.geoSection == null;

            if (newSection)
            {
                this.geoSection = new UPMResultSection(StringIdentifier.IdentifierWithStringId($"Search_{preparedSearch.InfoAreaId}"));
            }

            var count = result.RowCount;

            for (var j = 0; j < count; j++)
            {
                UPCRMResultRow dataRow    = result.ResultRowAtIndex(j) as UPCRMResultRow;
                var            identifier = new RecordIdentifier(preparedSearch.InfoAreaId, dataRow.RecordIdAtIndex(0));
                UPMResultRow   resultRow  = new UPMResultRow(identifier);
                resultRow.DataValid = true;
                resultContext.RowDictionary.SetObjectForKey(new UPCoreMappingResultRowContext(dataRow, resultContext), resultRow.Key);
                resultContext.ExpandMapper = preparedSearch.ExpandSettings;
                resultRow = (UPMResultRow)this.UpdatedElement(resultRow);

                this.AddDistanceFieldToRow(resultRow);
                this.geoSection.AddResultRow(resultRow);
                if (resultRow.RecordImageDocument != null)
                {
                    this.AnyResultWithImageField = true;
                }
            }

            List <GeoUPMResultRow> sortedArray = this.resultRowsToSort.OrderBy(a => a.Distance).ToList();

            this.geoSection.RemoveAllChildren();
            foreach (var row in sortedArray)
            {
                if (row.ResultRow != null)
                {
                    this.geoSection.AddResultRow(row.ResultRow);
                }
                else
                {
                }
            }

            return(newSection ? this.geoSection : null);
        }
        /// <summary>
        /// Searches the operation did finish with result.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="searchResult">The search result.</param>
        public void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult searchResult)
        {
            if (searchResult != null && searchResult.RowCount > 0)
            {
                DocumentInfoAreaManager documentInfoAreaManager = new DocumentInfoAreaManager(this.documentFieldControl.InfoAreaId, this.documentFieldControl, null);
                this.documentArray = new List <DocumentData>();
                for (int i = 0; i < searchResult.RowCount; i++)
                {
                    UPCRMResultRow resultRow = (UPCRMResultRow)searchResult.ResultRowAtIndex(i);
                    DocumentData   document  = documentInfoAreaManager.DocumentDataForResultRow(resultRow);
                    this.documentArray.Add(document);
                }
            }

            this.DocumentDelegate?.ObjectivesDocumentDidFinishFromSender(this);
        }
 /// <summary>
 /// Searches the operation did finish with result.
 /// </summary>
 /// <param name="operation">The operation.</param>
 /// <param name="result">The result.</param>
 public void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
 {
     if (result.RowCount > 0)
     {
         if (this.ParentController.ApplyResultRow((UPCRMResultRow)result.ResultRowAtIndex(0)) != null ||
             this.ParentController.ControllerState != GroupModelControllerState.Pending)
         {
             this.ControllerState = GroupModelControllerState.Finished;
             this.CallDelegate();
         }
     }
     else
     {
         this.ControllerState = GroupModelControllerState.Empty;
         this.CallDelegate();
     }
 }
예제 #28
0
        private void HandleRootOwnerResult(UPCRMResult result)
        {
            UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(0);

            this.RootRecordIdentification = row.RecordIdentificationAtIndex(0);
            this.ListingOwner             = new UPSEListingOwner(row, 0, this.RootListingOwnerMapping, this);
            if (!string.IsNullOrEmpty(this.ListingOwner.RecordIdentification))
            {
                this.listingOwners = new Dictionary <string, UPSEListingOwner> {
                    { this.ListingOwner.RecordIdentification, this.ListingOwner }
                };
                this.loadQueue = new List <object> {
                    this.ListingOwner
                };
            }

            this.LoadNextItemFromQueue();
        }
        private void HandleBundleResult(UPCRMResult result)
        {
            int count = result.RowCount;

            if (count > 0)
            {
                this.bundleDictionary = new Dictionary <string, UPSEBundlePricing>(count);
                for (int i = 0; i < count; i++)
                {
                    UPSEBundlePricing bundle = new UPSEBundlePricing((UPCRMResultRow)result.ResultRowAtIndex(i), this.ConfigFieldControl, this.Pricing);
                    this.bundleDictionary[bundle.RecordIdentification] = bundle;
                }

                this.StartBundleScaleQuery();
            }
            else
            {
                this.FinishedLoadingSuccessfully();
            }
        }
        private void HandleBaseResult(UPCRMResult result)
        {
            int count = result.RowCount;

            if (count > 0)
            {
                this.conditionDictionary = new Dictionary <string, UPSEPricingCondition>(count);
                int bundleKeyIndex = 0;
                if (this.BundleConfigFieldControl != null)
                {
                    int infoAreaIndex = this.currentQuery.IndexOfResultInfoAreaIdLinkId(this.BundleConfigFieldControl.InfoAreaId, -1);
                    if (infoAreaIndex > 0)
                    {
                        bundleKeyIndex = infoAreaIndex;
                    }
                }

                for (int i = 0; i < count; i++)
                {
                    UPSEPricingCondition condition = new UPSEPricingCondition(
                        (UPCRMResultRow)result.ResultRowAtIndex(i), this.ConfigFieldControl, bundleKeyIndex, this);

                    this.conditionDictionary[condition.RecordIdentification] = condition;
                }

                this.StartBaseScaleQuery();
            }
            else
            {
#if  PRICINGDEMO
                this.conditionDictionary = NSMutableDictionary.TheNew();
                this.bundleDictionary    = NSMutableDictionary.TheNew();
                UPSEPricingCondition condition     = UPSEPricingCondition.DemoBase();
                UPSEBundlePricing    bundlePricing = UPSEPricingCondition.DemoBundle();
                this.conditionDictionary.SetObjectForKey(condition, condition.RecordIdentification);
                this.bundleDictionary.SetObjectForKey(bundlePricing, bundlePricing.RecordIdentification);
#endif

                this.FinishedLoadingSuccessfully();
            }
        }