private int DetermineFieldIdDocumentUploadViewReference(int fieldId, ViewReference documentUploadViewReference)
        {
            string configValue = documentUploadViewReference.ContextValueForKey("DocumentFieldFieldGroupName");

            if (!string.IsNullOrEmpty(configValue))
            {
                FieldControl fieldControl = ConfigurationUnitStore.DefaultStore.FieldControlByNameFromGroup("Edit", configValue);
                if (fieldControl.NumberOfFields > 0)
                {
                    UPConfigFieldControlField field = fieldControl.FieldAtIndex(0);
                    if (field != null)
                    {
                        fieldId = field.FieldId;
                    }
                }
            }

            if (fieldId == -1)
            {
                configValue = documentUploadViewReference.ContextValueForKey("DocumentFieldId");
                if (!string.IsNullOrEmpty(configValue))
                {
                    fieldId = Convert.ToInt32(configValue);
                }
            }

            return(fieldId);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPCoreMappingResultContext"/> class.
        /// </summary>
        /// <param name="result">
        /// The result.
        /// </param>
        /// <param name="control">
        /// The control.
        /// </param>
        /// <param name="numberOfListFields">
        /// The number of list fields.
        /// </param>
        public UPCoreMappingResultContext(UPCRMResult result, FieldControl control, int numberOfListFields)
        {
            this.Result        = result;
            this.RowDictionary = new Dictionary <string, UPCoreMappingResultRowContext>();
            this.FieldControl  = control;

            this.NumberOfListFields = numberOfListFields;
            int controlFieldCount = control.NumberOfFields;

            if (numberOfListFields > controlFieldCount)
            {
                this.NumberOfListFields = controlFieldCount;
            }

            this.ListFormatter = new UPCRMListFormatter(control.TabAtIndex(0), this.NumberOfListFields);

            int dropdownLineFieldCount = controlFieldCount - numberOfListFields;

            if (dropdownLineFieldCount > 0)
            {
                List <UPConfigFieldControlField> fields = new List <UPConfigFieldControlField>(dropdownLineFieldCount);
                for (int i = numberOfListFields; i < numberOfListFields + dropdownLineFieldCount; i++)
                {
                    fields.Add(control.FieldAtIndex(i));
                }

                this.DropdownFields = fields;
            }

            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            this.InfoAreaConfig = configStore.InfoAreaConfigById(control.InfoAreaId);

            this.SectionFieldComplete = false;

            foreach (FieldControlTab tab in control.Tabs)
            {
                if (tab.Fields != null)
                {
                    foreach (UPConfigFieldControlField field in tab.Fields)
                    {
                        if (field.Attributes.ExtendedOptionIsSet(@"SectionField"))
                        {
                            this.SectionField = field;
                            break;
                        }
                    }
                }
            }

            this.SectionFieldComplete = this.SectionField != null && this.SectionField.Field.FieldType != @"C";
        }
Пример #3
0
        private bool IsOrganizerHeaderImageConfigured()
        {
            FieldControl fieldControl = ConfigurationUnitStore.DefaultStore.FieldControlByNameFromGroup("Details", this.ExpandConfig.FieldGroupName);

            if (fieldControl != null)
            {
                int numberOfFields = fieldControl.NumberOfFields;
                for (int index = 0; index < numberOfFields; index++)
                {
                    UPConfigFieldControlField field     = fieldControl.FieldAtIndex(index);
                    FieldAttribute            attribute = field.Attributes.AttributForId((int)FieldAttr.Image);
                    if (attribute != null)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPInBoxPageModelController"/> class.
        /// </summary>
        /// <param name="viewReference">The view reference.</param>
        public UPInBoxPageModelController(ViewReference viewReference)
            : base(viewReference)
        {
            UPMInBoxPage page = new UPMInBoxPage(StringIdentifier.IdentifierWithStringId("Inbox"))
            {
                Invalid = true,
                SkipUploadIfPossible = viewReference.ContextValueIsSet("SkipUploadPageIfPossible")
            };

            this.removeUploadedFileFromInbox = viewReference.ContextValueIsSet("RemoveUploadedFile");
            this.TopLevelElement             = page;
            this.editFieldContexts           = new Dictionary <StringIdentifier, UPEditFieldContext>();
            IConfigurationUnitStore configStore      = ConfigurationUnitStore.DefaultStore;
            FieldControl            editFieldControl = configStore.FieldControlByNameFromGroup("Edit", viewReference.ContextValueForKey("UploadFields"));
            UPMGroup uploadFieldGroup = new UPMGroup(StringIdentifier.IdentifierWithStringId("uploadFieldGroup"));

            if (editFieldControl != null)
            {
                int numberOfFields = editFieldControl.NumberOfFields;
                for (int index = 0; index < numberOfFields; index++)
                {
                    UPConfigFieldControlField field                 = editFieldControl.FieldAtIndex(index);
                    StringIdentifier          fieldIdentifier       = StringIdentifier.IdentifierWithStringId($"Field {field.FieldId} {field.InfoAreaId}");
                    UPEditFieldContext        initialValueEditField = UPEditFieldContext.FieldContextFor(field, fieldIdentifier, null, (List <UPEditFieldContext>)null);
                    this.editFieldContexts[fieldIdentifier] = initialValueEditField;
                    if (field.Function == "Filename")
                    {
                        page.FileNameEditField = initialValueEditField.EditField;
                    }

                    uploadFieldGroup.AddField(initialValueEditField.EditField);
                }
            }

            this.recordIdentification = this.ViewReference.ContextValueForKey("RecordId");
            page.UploadFieldGroup     = uploadFieldGroup; // load directly
            this.UpdatedElement(page);
        }
Пример #5
0
        private void Search(object _docPage)
        {
            UPMDocumentPage docPage = (UPMDocumentPage)_docPage;

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

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

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

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

                docPage.SearchPlaceholder = searchLabel;
            }

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

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

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

            if (docPage.SearchType == SearchPageSearchType.OfflineSearch)
            {
                this.currentSearchOperation = containerMetaInfo.Find(UPRequestOption.Offline, this);
            }
            else if (docPage.SearchType == SearchPageSearchType.OnlineSearch)
            {
                this.currentSearchOperation = containerMetaInfo.Find(this);
            }
            else
            {
                SimpleIoc.Default.GetInstance <ILogger>().LogError($"Unknown search type: {docPage.SearchType}");
            }
        }
        /// <summary>
        /// The result position of field.
        /// </summary>
        /// <param name="field">
        /// The field.
        /// </param>
        /// <param name="defaultResultFieldIndex">
        /// The default result field index.
        /// </param>
        /// <param name="fieldControl">
        /// The field control.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        private int ResultPositionOfField(
            UPConfigFieldControlField field,
            int defaultResultFieldIndex,
            FieldControl fieldControl)
        {
            if (field != null)
            {
                return(field.TabIndependentFieldIndex);
            }

            if (defaultResultFieldIndex < 0)
            {
                return(defaultResultFieldIndex);
            }

            if (defaultResultFieldIndex < fieldControl.NumberOfFields && string.IsNullOrEmpty(fieldControl.FieldAtIndex(defaultResultFieldIndex).Function))
            {
                return(defaultResultFieldIndex);
            }

            return(-1);
        }
Пример #7
0
        /// <summary>
        /// The formatted field value at index.
        /// </summary>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <param name="offset">
        /// The offset.
        /// </param>
        /// <param name="fieldControl">
        /// The field control.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string FormattedFieldValueAtIndex(int index, int?offset, FieldControl fieldControl)
        {
            UPConfigFieldControlField configField     = fieldControl.FieldAtIndex(index);
            FieldAttributes           fieldAttributes = configField.Attributes;
            string result = null;
            int    innerOffset;

            innerOffset = offset ?? 0;

            if (fieldAttributes.FieldCount > 1)
            {
                List <string> values = !string.IsNullOrEmpty(fieldAttributes.ExtendedOptionForKey("GPS"))
                    ? new List <string> {
                    this.RawValueAtIndex(configField.TabIndependentFieldIndex)
                }
                    : new List <string> {
                    this.ValueAtIndex(configField.TabIndependentFieldIndex)
                };

                int k;
                for (k = 1; k < fieldAttributes.FieldCount; k++)
                {
                    UPConfigFieldControlField childfieldConfig = fieldControl.FieldAtIndex(index + ++innerOffset);
                    if (childfieldConfig != null)
                    {
                        string value = (!string.IsNullOrEmpty(fieldAttributes.ExtendedOptionForKey("GPS"))
                            ? this.RawValueAtIndex(childfieldConfig.TabIndependentFieldIndex)
                            : this.ValueAtIndex(childfieldConfig.TabIndependentFieldIndex)) ?? string.Empty;

                        values.Add(value);
                    }
                }

                if (!string.IsNullOrEmpty(fieldAttributes.ExtendedOptionForKey("GPS")))
                {
                    bool firstFieldLongtitude = fieldAttributes.ExtendedOptionForKey("GPS") == "X";
                    if (values.Count >= 2)
                    {
#if PORTING
                        int longtitudeNumberValue;
                        int latitudeNumberValue;
                        if (firstFieldLongtitude)
                        {
                            longtitudeNumberValue = values[0].GpsLongtitudeNumberValue();
                            latitudeNumberValue   = values[1].GpsLatitudeNumberValue();
                        }
                        else
                        {
                            longtitudeNumberValue = values[1].GpsLongtitudeNumberValue();
                            latitudeNumberValue   = values[0].GpsLatitudeNumberValue();
                        }

                        string longtitudeString = longtitudeNumberValue.FormatedLongtitudeValue();
                        string lattitudeString  = latitudeNumberValue.FormatedLatitudeValue();
                        result = $"{lattitudeString} / {longtitudeString}";
#endif
                    }
                }
                else
                {
                    result = fieldAttributes.FormatValues(values);
                }
            }
            else
            {
                result = this.ValueAtIndex(configField.TabIndependentFieldIndex);
            }

            return(result);
        }