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();
        }
Exemple #2
0
        /// <summary>
        /// Searches the operation did finish with result.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="result">The result.</param>
        public override void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            TimelineSearch timelineSearch = this.searches[this.nextSearch++];

            timelineSearch.Result = result;
            this.ExecuteNextSearch();
        }
Exemple #3
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);
        }
        protected override void InitializeWithDestinationResult(UPCRMResult result, UPContainerMetaInfo searchOperation)
        {
            foreach (UPSEColumn column in this.Columns)
            {
                var destColumn = column as UPSEDestinationColumn;
                if (destColumn != null)
                {
                    switch (column.Function)
                    {
                    case "UnitPrice":
                        this.RowUnitPriceColumn = destColumn;
                        break;

                    case "EndPrice":
                        this.RowEndPriceColumn = destColumn;
                        break;

                    case "Quantity":
                        this.RowQuantityColumn = destColumn;
                        break;

                    case "FreeGoods":
                        this.RowFreeGoodsColumn = destColumn;
                        break;

                    case "NetPrice":
                        this.RowNetPriceColumn = destColumn;
                        break;
                    }
                }
            }

            this.ComputePriceForQuantity1 = ConfigurationUnitStore.DefaultStore.ConfigValueIsSet("SerialEntry.UnitPriceCheckPriceScaleFor1");
            base.InitializeWithDestinationResult(result, searchOperation);
        }
Exemple #5
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);
        }
Exemple #6
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)
        {
            this.crmQuery = null;
            switch (this.currentQueryType)
            {
            case 0:
                this.HandleGroupResult(result);
                break;

            case 1:
                this.HandleItemResult(result);
                break;

            case 2:
                this.HandleDestinationResult(result);
                break;

            case 3:
                this.HandleSourceFieldResult(result);
                break;

            default:
                break;
            }
        }
Exemple #7
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);
        }
Exemple #8
0
 /// <inheritdoc/>
 public override void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
 {
     this.Page.AddGroup(this.GroupFromResult(result));
     this.Page.Status  = null;
     this.Page.Invalid = false;
     this.InformAboutDidChangeTopLevelElement(this.Page, this.Page, null, null);
 }
Exemple #9
0
        private UPMGroup GroupFromResult(UPCRMResult result)
        {
            UPMDocumentsGroup docGroup = new UPMDocumentsGroup(this.TabIdentifierForRecordIdentification(this.RecordIdentification));

            docGroup.LabelText = this.TabLabel;
            int location = this.TabConfig.Type.IndexOf(".");

            if (location != -1)
            {
                string style = this.TabConfig.Type.Substring(location + 1);
                if (style.StartsWith("IMG"))
                {
                    docGroup.Style = UPMDocumentsGroupStyle.Image;
                }
                else if (style.StartsWith("NOIMG"))
                {
                    docGroup.Style = UPMDocumentsGroupStyle.NoImages;
                }
                else
                {
                    Logger.LogWarn($"Unknown style for DOC group: {style}");
                }
            }

            if (this.FillGroupWithLocalDocumentsResult(docGroup, result))
            {
                this.Group           = docGroup;
                this.ControllerState = GroupModelControllerState.Finished;
                return(docGroup);
            }

            this.Group           = null;
            this.ControllerState = GroupModelControllerState.Empty;
            return(null);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPSyncDocumentDownloadFieldGroupUrlCache"/> class.
        /// </summary>
        /// <param name="fieldGroupName">
        /// Name of the field group.
        /// </param>
        public UPSyncDocumentDownloadFieldGroupUrlCache(string fieldGroupName)
        {
            this.FieldControl = ConfigurationUnitStore.DefaultStore?.FieldControlByNameFromGroup("List", fieldGroupName);
            if (this.FieldControl != null)
            {
                var crmQuery = new UPContainerMetaInfo(this.FieldControl);
                this.result = crmQuery.Find();
                var count = this.result?.RowCount ?? 0;
                this.resultDictionary = new Dictionary <string, ICrmDataSourceRow>(count);
                for (var i = 0; i < count; i++)
                {
                    var row = this.result?.ResultRowAtIndex(i);
                    var rid = row?.RootRecordId;
                    if (!string.IsNullOrEmpty(rid))
                    {
                        this.resultDictionary[rid] = row;
                    }
                }
            }

            var fieldMapping = this.FieldControl?.FunctionNames();
            var field        = fieldMapping?.ValueOrDefault("UpdDate");

            this.ServerModifyDateFieldIndex = field?.TabIndependentFieldIndex ?? -1;

            field = fieldMapping?.ValueOrDefault("UpdTime");
            this.ServerModifyTimeFieldIndex = field?.TabIndependentFieldIndex ?? -1;

            this.HasServerDateTime = this.ServerModifyDateFieldIndex >= 0 && this.ServerModifyTimeFieldIndex >= 0;
        }
Exemple #11
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();
        }
Exemple #12
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();
        }
        /// <inheritdoc />
        public void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            var contextDelegate = this.ContextDelegate;

            this.ContextDelegate = null;
            contextDelegate.ExecutionContextDidFinishWithResult(this, result);
        }
Exemple #14
0
        /// <inheritdoc />
        public void SearchOperationDidFailWithError(Operation operation, Exception exception)
        {
            if ((this.RequestOption == UPRequestOption.BestAvailable || this.RequestOption == UPRequestOption.FastestAvailable) && this.error.IsConnectionOfflineError())
            {
                UPCRMResult result = this.crmQuery.Find();
                if (result?.RowCount > 0)
                {
                    this.controllerState   = GroupModelControllerState.Finished;
                    this.contactTimesGroup = this.GroupFromResult(result);
                }
                else
                {
                    this.contactTimesGroup = null;
                    return;
                }
            }
            else
            {
                this.controllerState   = GroupModelControllerState.Error;
                this.error             = exception;
                this.contactTimesGroup = null;
            }

            this.Delegate.GroupModelControllerFinished(this);
        }
        /// <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);
        }
        /// <inheritdoc/>
        public void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            ICurrencyConversionDelegate currencyDelegate = this.CurrencyDelegate;

            this.HandleResult(result);
            this.CurrencyDelegate = null;
            this.crmQuery         = null;
            currencyDelegate.CurrencyConversionDidFinishWithResult(this, this);
        }
        /// <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);
        }
Exemple #18
0
        private void HandleSourceFieldResult(UPCRMResult result)
        {
            if (result?.RowCount > 0)
            {
                this.sourceFieldDictionary = this.SourceFieldControl.FunctionNames((UPCRMResultRow)result.ResultRowAtIndex(0));
            }

            this.LoadGroups();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UPLocalSearchOperationWithResult"/> class.
 /// </summary>
 /// <param name="result">
 /// The result.
 /// </param>
 /// <param name="query">
 /// The query.
 /// </param>
 /// <param name="handler">
 /// The handler.
 /// </param>
 public UPLocalSearchOperationWithResult(
     UPCRMResult result,
     UPContainerMetaInfo query,
     ISearchOperationHandler handler)
 {
     this.crmResult = result;
     this.crmQuery  = query;
     this.SearchOperationHandler = handler;
 }
Exemple #20
0
 private void FailWithError(Exception error)
 {
     this.allItems                     = null;
     this.allItemsResult               = null;
     this.filterItemsResult            = null;
     this.objectivesForRecordOperation = null;
     this.rightFilterOperation         = null;
     this.TheDelegate?.ObjectivesDidFailWithError(this, error);
 }
Exemple #21
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);
        }
Exemple #22
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));
                    }
                }
            }
        }
Exemple #24
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]));
                }
            }
        }
Exemple #25
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>
        /// 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 == null)
            {
                result = UPCRMResult.EmptyClientResult();
            }

            this.resultsForClientReports[this.nextClientReport++] = result;
            this.crmQuery = null;
            this.ComputeNextReport();
        }
Exemple #27
0
 /// <summary>
 /// Ups 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 != null && result.RowCount > 0)
     {
         this.Delegate?.RightsCheckerGrantsPermission(this.RightsChecker, this.RecordIdentification);
     }
     else
     {
         this.Delegate?.RightsCheckerRevokePermission(this.RightsChecker, this.RecordIdentification);
     }
 }
 /// <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 (this.loadStep == 1)
     {
         this.ApplyArticleConfigurationResult(result);
     }
     else if (this.loadStep == 2)
     {
         this.ApplyQuotaResult(result);
     }
 }
        /// <summary>
        /// Creates the new search page with result.
        /// </summary>
        /// <param name="results">The results.</param>
        public virtual void CreateNewSearchPageWithResult(List <UPCRMResult> results)
        {
            UPMSearchPage newPage = new UPMSearchPage(this.Page.Identifier);

            newPage.CopyDataFrom(this.SearchPage);
            newPage.Invalid = false;
            int searchCount = this.PreparedSearches?.Count ?? 0;

            for (int i = 0; i < searchCount && i < results.Count; i++)
            {
                UPSearchPageModelControllerPreparedSearch preparedSearch = this.PreparedSearches[i];
                if (results[i] != null)
                {
                    UPCRMResult result = results[i];
                    if (result.RowCount > 0)
                    {
                        UPMResultSection section = this.ResultSectionForSearchResult(preparedSearch, result);
                        if (section != null)
                        {
                            newPage.AddResultSection(section);
                        }
                    }
                }
            }

            // Hardcoded Detail Action
            UPMAction switchToDetailAction = new UPMAction(null);

            switchToDetailAction.IconName = "arrow.png";
            switchToDetailAction.SetTargetAction(this, this.SwitchToDetail);
            newPage.RowAction = switchToDetailAction;

            UPMAction searchAction = new UPMAction(null);

            searchAction.SetTargetAction(this, this.Search);
            newPage.SearchAction = searchAction;

            UPMSearchPage oldSearchPage = this.SearchPage;

            this.TopLevelElement = newPage;
            SearchPageResultState state = SearchPageResultState.OfflineNoLokalData;

            foreach (UPCRMResult result in results)
            {
                if (result != null && result.RowCount > 0)
                {
                    state = SearchPageResultState.Ok;
                }
            }

            newPage.ResultState = state;
            this.InformAboutDidChangeTopLevelElement(oldSearchPage, newPage, null, null);
        }
Exemple #30
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);
            }
        }