コード例 #1
0
        private UPMGroup GroupFromRow(UPCRMResultRow resultRow)
        {
            if (resultRow.IsNewRow)
            {
                this.ParticipantsControl = new UPCRMMutableParticipants(
                    null,
                    resultRow.RootRecordIdentification.InfoAreaId(),
                    resultRow.RootRecordIdentification,
                    null,
                    -1,
                    this);

                var parentInitialValues            = this.EditPageContext.InitialValues;
                var childGroupKey                  = this.ChildGroupKey;
                var parentInitialValueDictionaries = parentInitialValues.ValueOrDefault(childGroupKey) as List <Dictionary <string, object> >;

                if (parentInitialValueDictionaries?.Count > 0)
                {
                    foreach (var parentInitialValueForChild in parentInitialValueDictionaries)
                    {
                        string value = null;
                        Dictionary <string, object> options = null;
                        foreach (var key in parentInitialValueForChild.Keys)
                        {
                            if (key == ".Options")
                            {
                                var optionStringArray = parentInitialValueForChild.ValueOrDefault(key) as List <string>;
                                options = OptionsFromStringArray(optionStringArray);
                            }
                            else if (value == null)
                            {
                                value = parentInitialValueForChild.ValueOrDefault(key) as string;
                            }
                        }

                        if (!string.IsNullOrEmpty(value))
                        {
                            this.ParticipantsControl.AddRepParticipantWithRepId(value, options);
                        }
                        else
                        {
                            this.firstItemOptions = options;
                        }
                    }
                }

                if (this.ParticipantsField != null)
                {
                    this.editFieldContext = new UPParticipantsEditFieldContext(this.ParticipantsField, null, string.Empty, null);
                }
            }
            else if (this.ParticipantsField != null)
            {
                this.LinkRecordIdentification = resultRow.RootRecordIdentification;
                var participantsString = resultRow.ValueAtIndex(this.ParticipantsField.TabIndependentFieldIndex);
                this.ParticipantsControl = new UPCRMMutableParticipants(null, null, resultRow.RootRecordIdentification, null, -1, this);
                this.editFieldContext    = new UPParticipantsEditFieldContext(this.ParticipantsField, null, participantsString, null);
                this.ParticipantsControl.AddParticipantsFromString(participantsString);
            }
            else
            {
                this.Group           = null;
                this.ControllerState = GroupModelControllerState.Empty;
                return(this.Group);
            }

            if (this.editFieldContext != null)
            {
                this.editFieldContext.GroupModelController = this;
                this.EditPageContext.EditFields.SetObjectForKey(this.editFieldContext, this.editFieldContext.Key);
            }

            if (!string.IsNullOrEmpty(this.LinkParticipantsName))
            {
                this.ParticipantsControl?.SetFieldsFromSearchAndListConfigurationName(this.LinkParticipantsName);
            }

            if (this.AddRecordEnabled || this.ParticipantsControl?.Participants.Count > 0)
            {
                this.ControllerState = GroupModelControllerState.Pending;
                this.ParticipantsControl?.Load();
            }
            else
            {
                this.Group           = null;
                this.ControllerState = GroupModelControllerState.Empty;
            }

            this.signalFinished = true;
            return(this.Group);
        }
コード例 #2
0
        UPMGroup GroupFromRow(UPCRMResultRow resultRow)
        {
            if (resultRow.IsNewRow())
            {
                this.ParticipantsControl = new UPCRMMutableParticipants(null, resultRow.RootRecordIdentification.InfoAreaId(), null, -1, null, this);
                NSDictionary parentInitialValues            = this.EditPageContext.initialValues;
                string       childGroupKey                  = this.ChildGroupKey();
                ArrayList    parentInitialValueDictionaries = parentInitialValues.ObjectForKey(childGroupKey);
                if (parentInitialValueDictionaries.Count > 0)
                {
                    if (parentInitialValueDictionaries != null)
                    {
                        foreach (NSDictionary parentInitialValueForChild in parentInitialValueDictionaries)
                        {
                            string       value   = null;
                            NSDictionary options = null;
                            foreach (string key in parentInitialValueForChild)
                            {
                                if (key.IsEqualToString(".Options"))
                                {
                                    ArrayList optionStringArray = parentInitialValueForChild.ObjectForKey(key);
                                    options = UPEditChildrenGroupModelControllerBase.OptionsFromStringArray(optionStringArray);
                                }
                                else if (value == null)
                                {
                                    value = parentInitialValueForChild.ObjectForKey(key);
                                }
                            }
                            if (value.Length > 0)
                            {
                                this.ParticipantsControl.AddRepParticipantWithRepIdWithOptions(value, options);
                            }
                            else
                            {
                                firstItemOptions = options;
                            }
                        }
                    }
                }

                if (this.ParticipantsField != null)
                {
                    editFieldContext = new UPParticipantsEditFieldContext(this.ParticipantsField, null, string.Empty, null);
                }
            }
            else if (this.ParticipantsField != null)
            {
                this.LinkRecordIdentification = resultRow.RootRecordIdentification();
                string participantsString = resultRow.ValueAtIndex(this.ParticipantsField.TabIndependentFieldIndex);
                this.ParticipantsControl = new UPCRMMutableParticipants(null, null, null, -1, resultRow.RootRecordIdentification(), this);
                editFieldContext         = new UPParticipantsEditFieldContext(this.ParticipantsField, null, participantsString, null);
                this.ParticipantsControl.AddParticipantsFromString(participantsString);
            }
            else
            {
                this.Group           = null;
                this.ControllerState = UPGroupModelControllerStateEmpty;
                return(this.Group);
            }

            if (editFieldContext != null)
            {
                editFieldContext.GroupModelController = this;
                this.EditPageContext.EditFields.SetObjectForKey(editFieldContext, editFieldContext.Key);
            }

            if (this.LinkParticipantsName.Length)
            {
                this.ParticipantsControl.SetFieldsFromSearchAndListConfigurationName(this.LinkParticipantsName);
            }

            if (this.AddRecordEnabled || this.ParticipantsControl.Participants.Count > 0)
            {
                this.ControllerState = UPGroupModelControllerStatePending;
                this.ParticipantsControl.Load();
            }
            else
            {
                this.Group           = null;
                this.ControllerState = UPGroupModelControllerStateEmpty;
            }

            signalFinished = true;
            return(this.Group);
        }