Пример #1
0
        /// <summary>
        /// Raws the value for field.
        /// </summary>
        /// <param name="fieldMetaInfo">
        /// The field meta information.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string RawValueForField(UPContainerFieldMetaInfo fieldMetaInfo)
        {
            if (fieldMetaInfo == null || !string.IsNullOrEmpty(this.newRecordIdentification))
            {
                return(string.Empty);
            }

            if (this.databaseRow != null)
            {
                var row = this.databaseRow;
                var val = row.GetColumn(fieldMetaInfo.PositionInResult);
                return(val ?? string.Empty);
            }

            if (this.IsServerResponse)
            {
                if (this.Result.HasMultipleOutputInfoAreas)
                {
                    var pointer    = this.Result.ServerMap()[fieldMetaInfo.PositionInServerResultMap];
                    var recordData = this.serverData[pointer.RecordIndex];
                    return(recordData is List <object>
                           ?((List <object>)recordData)[pointer.FieldIndex] as string
                           : string.Empty);
                }
                else
                {
                    var recordData = this.serverData.Count > 0 ? this.serverData[0] as List <object> : null;
                    return(recordData != null && recordData.Count > fieldMetaInfo.PositionInResult
                               ? recordData[fieldMetaInfo.PositionInResult] as string
                               : string.Empty);
                }
            }

            return(string.Empty);
        }
Пример #2
0
        /// <summary>
        /// Values for field.
        /// </summary>
        /// <param name="fieldMetaInfo">
        /// The field meta information.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string ValueForField(UPContainerFieldMetaInfo fieldMetaInfo)
        {
            var rawValue = this.RawValueForField(fieldMetaInfo);
            var value    = fieldMetaInfo.ValueFromRawValue(rawValue);

            return(value ?? string.Empty);
        }
Пример #3
0
        private void TrySourceCopyFieldGroupOfflineWithRecordLink()
        {
            if (!UPCRMDataStore.DefaultStore.RecordExistsOffline(this.RecordIdentification))
            {
                this.TheDelegate.SurveyDidFailWithError(this, new Exception("SourceCopyFields could not be loaded"));
                return;
            }

            this.crmQuery = this.SourceCopyFieldGroup != null
                ? new UPContainerMetaInfo(this.SourceCopyFieldGroup)
                : new UPContainerMetaInfo(new List <UPCRMField>(), this.RecordIdentification.InfoAreaId());

            UPQuestionnaireManager          questionnaireManager   = ServerSession.CurrentSession.QuestionnaireManager;
            UPCRMLinkField                  questionnairelinkField = new UPCRMLinkField(questionnaireManager.QuestionnaireList.InfoAreaId, -1, this.RecordIdentification.InfoAreaId());
            List <UPContainerFieldMetaInfo> fieldMetaInfos         = this.crmQuery.AddCrmFields(new List <UPCRMField> {
                questionnairelinkField
            });

            if (fieldMetaInfos.Count > 0)
            {
                this.questionnairelinkFieldMetaInfo = fieldMetaInfos[0];
            }

            this.crmQuery.SetLinkRecordIdentification(this.RecordIdentification);
            this.loadStep = 1;
            this.crmQuery.Find(UPRequestOption.Offline, this);
        }
Пример #4
0
        /// <summary>
        /// Displays the value for raw value.
        /// </summary>
        /// <param name="rawValue">The raw value.</param>
        /// <returns></returns>
        public string DisplayValueForRawValue(string rawValue)
        {
            if (this.fieldMetaInfo == null)
            {
                this.fieldMetaInfo = new UPContainerFieldMetaInfo(this.FieldConfig.Field, null, this.FieldConfig.Field);
            }

            return(this.fieldMetaInfo.ValueFromRawValue(rawValue));
        }
Пример #5
0
        /// <summary>
        /// Reports the value from raw value.
        /// </summary>
        /// <param name="rawValue">
        /// The raw value.
        /// </param>
        /// <returns>
        /// report valu
        /// </returns>
        public string ReportValueFromRawValue(string rawValue)
        {
            if (this.fieldMetaInfo == null)
            {
                this.fieldMetaInfo = new UPContainerFieldMetaInfo(this);
            }

            return(this.fieldMetaInfo.ReportValueFromRawValue(rawValue));
        }
Пример #6
0
        /// <summary>
        /// Shorts the value from raw value options.
        /// </summary>
        /// <param name="rawValue">
        /// The raw value.
        /// </param>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <returns>
        /// short value
        /// </returns>
        public string ShortValueFromRawValueOptions(string rawValue, UPFormatOption options)
        {
            if (this.fieldMetaInfo == null)
            {
                this.fieldMetaInfo = new UPContainerFieldMetaInfo(this);
            }

            return(this.fieldMetaInfo.ShortValueFromRawValue(rawValue, options));
        }
        /// <summary>
        /// Results the field map from meta information.
        /// </summary>
        /// <param name="metaInfo">The meta information.</param>
        /// <returns>table caption</returns>
        public List <UPContainerFieldMetaInfo> ResultFieldMapFromMetaInfo(UPContainerMetaInfo metaInfo)
        {
            var resultFieldPosition = new List <UPContainerFieldMetaInfo>();
            var foundCount          = 0;

            if (this.Fields != null)
            {
                foreach (var field in this.Fields)
                {
                    UPContainerFieldMetaInfo foundField = null;
                    if (metaInfo?.OutputFields != null)
                    {
                        foreach (var fieldMetaInfo in metaInfo.OutputFields)
                        {
                            if (!fieldMetaInfo.CrmField.IsEqualToField(field))
                            {
                                continue;
                            }

                            foundField = fieldMetaInfo;
                            break;
                        }
                    }

                    if (foundField != null)
                    {
                        ++foundCount;
                        resultFieldPosition.Add(foundField);
                    }
                    else
                    {
                        resultFieldPosition.Add(null);
                    }
                }
            }

            return(foundCount > 0 ? resultFieldPosition : null);
        }
        private void UpdatePageFromQueryResult(UPCRMResult result)
        {
            this.QueryResult = result;
            UPMGridPage      searchPage = (UPMGridPage)this.CreatePageInstance();
            Page             oldPage = this.Page;
            int              i, j;
            int              columnCount         = result.ColumnCount;
            StringIdentifier identifier          = StringIdentifier.IdentifierWithStringId("columnHeader");
            UPMResultSection section             = new UPMResultSection(identifier);
            UPMResultRow     columnHeaderListRow = new UPMResultRow(identifier);
            var              fieldArray          = new List <UPMField>();

            searchPage.FixedFirstColumn = false;
            searchPage.ShowMenu         = true;
            searchPage.SumRowAtEnd      = false;
            for (i = 0; i < columnCount; i++)
            {
                UPContainerFieldMetaInfo fieldMetaInfo = result.ColumnFieldMetaInfoAtIndex(i);
                string fieldType = fieldMetaInfo.CrmFieldInfo.FieldType;
                if (fieldType == "F" || fieldType == "L" || fieldType == "S")
                {
                    searchPage.SetColumnInfoAtIndexDataTypeSpecialSort(i, UPMColumnDataType.Numeric, false);
                }
                else if (fieldType == "D")
                {
                    searchPage.SetColumnInfoAtIndexDataTypeSpecialSort(i, UPMColumnDataType.Date, true);
                }

                UPMGridColumnHeaderStringField field = new UPMGridColumnHeaderStringField(StringIdentifier.IdentifierWithStringId($"col {i}"))
                {
                    StringValue = result.ColumnNameAtIndex(i)
                };
                fieldArray.Add(field);
            }

            columnHeaderListRow.Fields = fieldArray;
            section.AddResultRow(columnHeaderListRow);
            searchPage.AddResultSection(section);
            int           numberOfResultTables = result.NumberOfResultTables;
            List <object> contextMenuOptions   = new List <object>(numberOfResultTables);
            var           configStore          = ConfigurationUnitStore.DefaultStore;

            for (j = 0; j < numberOfResultTables; j++)
            {
                string infoAreaId    = result.ResultTableAtIndex(j).InfoAreaId;
                string infoAreaLabel = string.Empty;
                if (infoAreaId?.Length > 0)
                {
                    InfoArea       configInfoArea = configStore.InfoAreaConfigById(infoAreaId);
                    UPConfigExpand expand         = configStore.ExpandByName(infoAreaId);
                    FieldControl   fieldControl   = configStore.FieldControlByNameFromGroup("Details", expand.FieldGroupName);
                    if (configInfoArea != null && expand != null && fieldControl != null)
                    {
                        infoAreaLabel = LocalizedString.TextAnalysesShowParam.Replace("%@", configInfoArea.SingularName);
                    }
                }

                contextMenuOptions.Add(infoAreaLabel);
            }

            for (i = 0; i < result.RowCount; i++)
            {
                identifier = StringIdentifier.IdentifierWithStringId($"row {i}");
                var listRow = new UPMResultRow(identifier);
                var crmRow  = result.ResultRowAtIndex(i) as UPCRMResultRow;
                fieldArray = new List <UPMField>();
                var v = crmRow.Values();
                for (j = 0; j < v.Count; j++)
                {
                    UPMStringField field2 = new UPMStringField(StringIdentifier.IdentifierWithStringId($"cell{i}_{j}"))
                    {
                        StringValue    = v[j],
                        RawStringValue = crmRow.RawValueAtIndex(j)
                    };
                    fieldArray.Add(field2);
                }

                listRow.Fields = fieldArray;
                section.AddResultRow(listRow);
                for (j = 0; j < numberOfResultTables; j++)
                {
                    var label = contextMenuOptions[j] as string;
                    if (label.Length == 0)
                    {
                        continue;
                    }

                    string recordIdentification = crmRow.RecordIdentificationAtIndex(j);
                    if (recordIdentification?.Length > 0)
                    {
                        UPMOrganizerAnalysisShowRecordAction showRecordAction = new UPMOrganizerAnalysisShowRecordAction(StringIdentifier.IdentifierWithStringId($"action.row {i} record {j}"))
                        {
                            RecordIdentification = recordIdentification
                        };
                        showRecordAction.SetTargetAction(this, this.PerformShowRecordAction);
                        showRecordAction.LabelText = label;
                        listRow.AddDetailAction(showRecordAction);
                    }
                }
            }

            this.TopLevelElement = searchPage;
            this.InformAboutDidChangeTopLevelElement(oldPage, searchPage, null, null);
        }
Пример #9
0
        /// <summary>
        /// Loads this instance.
        /// </summary>
        /// <returns></returns>
        public bool Load()
        {
            bool isRecordLink = false;

            if (string.IsNullOrEmpty(this.QuestionnaireLinkName))
            {
                this.QuestionnaireLinkName = "RecordLink";
            }

            this.loadStep = 1;
            this.crmQuery = this.SourceCopyFieldGroup != null
                ? new UPContainerMetaInfo(this.SourceCopyFieldGroup)
                : new UPContainerMetaInfo(new List <UPCRMField>(), this.RecordIdentification.InfoAreaId());

            if (this.QuestionnaireLinkName == "RecordLink")
            {
                isRecordLink = true;
                UPQuestionnaireManager questionnaireManager = null; //ServerSession.CurrentSession.QuestionnaireManager;
                if (this.SourceRequestOption == UPRequestOption.Offline ||
                    ((this.SourceRequestOption == UPRequestOption.FastestAvailable || this.SourceRequestOption == UPRequestOption.Default) &&
                     UPCRMDataStore.DefaultStore.RecordExistsOffline(this.RecordIdentification)))
                {
                    UPCRMLinkField questionnairelinkField          = new UPCRMLinkField(questionnaireManager.QuestionnaireList.InfoAreaId, -1, this.RecordIdentification.InfoAreaId());
                    List <UPContainerFieldMetaInfo> fieldMetaInfos = this.crmQuery.AddCrmFields(new List <UPCRMField> {
                        questionnairelinkField
                    });
                    if (fieldMetaInfos.Count > 0)
                    {
                        this.questionnairelinkFieldMetaInfo = fieldMetaInfos[0];
                    }
                }
                else
                {
                    UPCRMField questionnairelinkField = new UPCRMField(0, questionnaireManager?.QuestionnaireList.InfoAreaId, -1);
                    UPContainerInfoAreaMetaInfo subInfoAreaMetaInfo = this.crmQuery.RootInfoAreaMetaInfo.SubTableForInfoAreaIdLinkId(questionnaireManager?.QuestionnaireList.InfoAreaId, -1);
                    if (subInfoAreaMetaInfo == null)
                    {
                        this.crmQuery.RootInfoAreaMetaInfo.AddTable(new UPContainerInfoAreaMetaInfo(questionnaireManager?.QuestionnaireList.InfoAreaId, -1));
                    }

                    this.crmQuery.AddCrmFields(new List <UPCRMField> {
                        questionnairelinkField
                    });
                }
            }

            this.crmQuery.SetLinkRecordIdentification(this.RecordIdentification);
            if (isRecordLink && this.SourceRequestOption == UPRequestOption.BestAvailable)
            {
                this.loadStep = 11;
                if (this.crmQuery.Find(UPRequestOption.Online, this) == null)
                {
                    this.TrySourceCopyFieldGroupOfflineWithRecordLink();
                }
            }
            else
            {
                this.crmQuery.Find(this.SourceRequestOption, this);
            }

            return(true);
        }