Ejemplo n.º 1
0
        /// <summary>
        /// Creates and returns an instance of <see cref="UPMGroup"/> from given <see cref="UPCRMResultRow"/>.
        /// </summary>
        /// <param name="resultRow">
        /// The result row.
        /// </param>
        /// <returns>
        /// The <see cref="UPMGroup"/>.
        /// </returns>
        private UPMGroup GroupFromRow(UPCRMResultRow resultRow)
        {
            var location             = UPGeoLocation.Create(resultRow, this.TabConfig);
            var recordIdentification = resultRow.RootRecordIdentification;

            if (location != null)
            {
                var mapGroup = new UPMMapGroup(this.TabIdentifierForRecordIdentification(recordIdentification));
                mapGroup.LabelText = this.TabLabel;
                var locationField = new UPMLocationField(FieldIdentifier.IdentifierWithRecordIdentificationFieldId(recordIdentification, "locationField"), null);

                if (location.ValidGPS)
                {
                    locationField.Longitude = location.GpsXString;
                    locationField.Latitude  = location.GpsYString;
                }

                if (!string.IsNullOrEmpty(location.AddressTitle))
                {
                    locationField.AddressTitle = location.AddressTitle;
                }

                if (!string.IsNullOrEmpty(location.Address))
                {
                    locationField.Address = location.Address;
                }

                mapGroup.AddChild(locationField);
                this.ControllerState = GroupModelControllerState.Finished;
                this.Group           = mapGroup;
                return(mapGroup);
            }

            this.ControllerState = GroupModelControllerState.Empty;
            return(null);
        }
        /// <summary>
        /// The group from result.
        /// </summary>
        /// <param name="result">
        /// The result.
        /// </param>
        /// <returns>
        /// The <see cref="UPMGroup"/>.
        /// </returns>
        protected override UPMGroup GroupFromResult(UPCRMResult result)
        {
            int count = result.RowCount;

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

            if (count > 0)
            {
                var mapGroup = new UPMMapGroup(this.ExplicitTabIdentifier)
                {
                    LabelText = this.TabLabel
                };

                if (this.FormItem != null)
                {
                    var optionValue = this.FormItem.Options.ValueOrDefault("Interaction") as string;

                    mapGroup.UserInteractionOnlyEnabledInFullscreenMode = optionValue == "FullScreen";

                    mapGroup.RecommendedHeight = this.FormItem.CellAttributes.ValueOrDefault("Height").ToInt();
                }
                else
                {
                    mapGroup.RecommendedHeight = 350;
                }

                var tabConfig = this.FieldControl.TabAtIndex(0);

                for (var i = 0; i < count; i++)
                {
                    var resultRow   = (UPCRMResultRow)result.ResultRowAtIndex(i);
                    var geoLocation = UPGeoLocation.Create(resultRow, tabConfig);
                    if (geoLocation == null)
                    {
                        continue;
                    }

                    var identifier          = new RecordIdentifier(this.FieldControl.InfoAreaId, resultRow.RecordIdentificationAtIndex(0).RecordId());
                    var locationFieldAction = new UPMAction(identifier.IdentifierWithFieldId("locationActionId"));
                    locationFieldAction.SetTargetAction(this, this.PerformLocationFieldAction);
                    var locationField = new UPMLocationField(identifier, locationFieldAction);
                    if (geoLocation.ValidGPS)
                    {
                        locationField.Longitude = geoLocation.GpsXString;
                        locationField.Latitude  = geoLocation.GpsYString;
                    }

                    if (!string.IsNullOrEmpty(geoLocation.AddressTitle))
                    {
                        locationField.AddressTitle = geoLocation.AddressTitle;
                    }

                    if (!string.IsNullOrEmpty(geoLocation.Address))
                    {
                        locationField.Address = geoLocation.Address;
                    }

                    mapGroup.AddChild(locationField);
                }

                this.ControllerState = GroupModelControllerState.Finished;
                this.Group           = mapGroup;
                return(mapGroup);
            }

            this.ControllerState = GroupModelControllerState.Empty;
            this.Group           = null;
            return(null);
        }