/// <summary>
        /// The create edit field.
        /// </summary>
        /// <returns>
        /// The <see cref="UPMEditField"/>.
        /// </returns>
        public override UPMEditField CreateEditField()
        {
            UPMRepEditField field            = new UPMRepEditField(this.FieldIdentifier);
            UPCRMRepType    repType          = UPCRMReps.RepTypeFromString(this.FieldConfig.Field.RepType);
            var             possibleValues   = UPCRMDataStore.DefaultStore.Reps.AllRepsOfTypes(repType);
            var             explicitKeyOrder = UPCRMDataStore.DefaultStore.Reps.AllRepIdsOfTypes(repType);
            var             repContainer     = UPRepsService.CreateRepContainerForRepType(repType);

            field.RepContainer = repContainer;

            // Adding all rep values from UPCRMDataStore to the PossibleValues list.
            foreach (var obj in possibleValues)
            {
                UPMCatalogPossibleValue possibleValue = new UPMCatalogPossibleValue();
                UPMStringField          valueField    = new UPMStringField(StringIdentifier.IdentifierWithStringId("x"));
                UPCRMRep rep = obj;
                valueField.StringValue        = rep.RepName;
                possibleValue.TitleLabelField = valueField;
                possibleValue.Key             = rep.RepId;
                field.AddPossibleValue(possibleValue);
            }

            field.SetFieldValue(this.OriginalValue);
            field.NullValueKey     = "0";
            field.ExplicitKeyOrder = explicitKeyOrder;
            this.ApplyAttributesOnEditFieldConfig(field, this.FieldConfig);

            return(field);
        }
 /// <summary>
 /// Alls the rep ids of types.
 /// </summary>
 /// <param name="typeMask">The type mask.</param>
 /// <returns></returns>
 public List <string> AllRepIdsOfTypes(UPCRMRepType typeMask)
 {
     if (typeMask == UPCRMRepType.All)
     {
         return(this.RepArray.Select(r => r.RepId).ToList());
     }
     else
     {
         return(this.RepArray.Where(r => r.RepType == typeMask).Select(r => r.RepId).ToList());
     }
 }
Exemple #3
0
        UPMEditField CreateMainEditFieldWithParticipantIdentifierEditGroup(UPMIdentifier participantIdentifier, UPMGroup editGroup)
        {
            UPMRepEditField editField = new UPMRepEditField(participantIdentifier);

            editField.Group = editGroup;
            editField.GroupModelController = this;
            editField.MultiSelectMode      = true;
            editField.HelpIdentifier       = UPMStringIdentifier.IdentifierWithStringId("RepPartitipant");
            UPCRMRepType   repType     = UPCRMReps.RepTypeFromString(this.ParticipantsField.Field.RepType);
            UPMRepContaner repContaner = UPRepsService.CreateRepContanerForRepType(repType);

            editField.RepContaner      = repContaner;
            editField.ContinuousUpdate = true;
            return(editField);
        }
        /// <summary>
        /// Gets all the reps types.
        /// </summary>
        /// <param name="typeMask">The type mask.</param>
        /// <returns></returns>
        public List <UPCRMRep> AllRepsOfTypes(UPCRMRepType typeMask)
        {
            if (typeMask == UPCRMRepType.All)
            {
                return(this.RepArray);
            }

            var list = new List <UPCRMRep>();

            foreach (UPCRMRepType repType in Enum.GetValues(typeof(UPCRMRepType)).Cast <UPCRMRepType>())
            {
                if (typeMask.HasFlag(repType))
                {
                    list.AddRange(this.RepArray.Where(rep => rep.RepType == repType));
                }
            }

            return(list);
        }
        /// <summary>
        /// Alls the type of the root groups with.
        /// </summary>
        /// <param name="repType">Type of the rep.</param>
        /// <returns></returns>
        public List <UPCRMRep> AllRootGroupsWithType(UPCRMRepType repType)
        {
            var repGroupArray = new List <UPCRMRep>();

            foreach (var repGroup in this.RepArray)
            {
                if (repGroup.RepType != UPCRMRepType.Group ||
                    (!string.IsNullOrEmpty(repGroup.RepOrgGroupId) && this.repDictionary.ValueOrDefault(repGroup.RepOrgGroupId) != null))
                {
                    continue;
                }

                if (this.RepGroupHasChildrenOfTypeRecursive(repGroup, repType, true))
                {
                    repGroupArray.Add(repGroup);
                }
            }

            return(repGroupArray);
        }
        /// <summary>
        /// Gets the Rep type from string.
        /// </summary>
        /// <param name="strRepType">Type of the string rep.</param>
        /// <returns></returns>
        public static UPCRMRepType RepTypeFromString(string strRepType)
        {
            UPCRMRepType repType = 0;

            if (strRepType == "Rep" || strRepType.IndexOf("Rep.Rep", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                repType = UPCRMRepType.Rep;
            }

            if (strRepType.IndexOf("Rep.Group", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                repType |= UPCRMRepType.Group;
            }

            if (strRepType.IndexOf("Rep.Resource", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                repType |= UPCRMRepType.Resource;
            }

            return(repType);
        }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPCRMRep"/> class.
 /// </summary>
 /// <param name="repId">
 /// The rep identifier.
 /// </param>
 /// <param name="orgGroupId">
 /// The org group identifier.
 /// </param>
 /// <param name="name">
 /// The name.
 /// </param>
 /// <param name="recordIdentification">
 /// The record identification.
 /// </param>
 /// <param name="repType">
 /// Type of the rep.
 /// </param>
 public UPCRMRep(string repId, string orgGroupId, string name, string recordIdentification, UPCRMRepType repType)
 {
     this.RepId                = repId.RepIdString();
     this.RepOrgGroupId        = orgGroupId.RepIdString();
     this.RepName              = name;
     this.RecordIdentification = recordIdentification;
     this.RepType              = repType;
 }
 /// <summary>
 /// Alls the rep names of types.
 /// </summary>
 /// <param name="typeMask">The type mask.</param>
 /// <returns></returns>
 public List <string> AllRepNamesOfTypes(UPCRMRepType typeMask)
 {
     return(this.RepArray.Where(r => r.RepType == typeMask).Select(r => r.RepName).ToList());
 }
 /// <summary>
 /// Childrens the of group with type recursive.
 /// </summary>
 /// <param name="rep">The rep.</param>
 /// <param name="repType">Type of the rep.</param>
 /// <param name="recursive">if set to <c>true</c> [recursive].</param>
 /// <returns></returns>
 public List <UPCRMRep> ChildrenOfGroupWithTypeRecursive(UPCRMRep rep, UPCRMRepType repType, bool recursive)
 {
     return(this.ChildrenOfGroupWithIdWithTypeRecursive(rep.RepId, repType, recursive));
 }
 /// <summary>
 /// Reps the group has children of type recursive.
 /// </summary>
 /// <param name="rep">The rep.</param>
 /// <param name="repType">Type of the rep.</param>
 /// <param name="recursive">if set to <c>true</c> [recursive].</param>
 /// <returns></returns>
 public bool RepGroupHasChildrenOfTypeRecursive(UPCRMRep rep, UPCRMRepType repType, bool recursive)
 {
     return(this.RepGroupWithIdHasChildrenOfTypeRecursive(rep.RepId, repType, recursive));
 }
        /// <summary>
        /// Childrens the of group with identifier with type recursive.
        /// </summary>
        /// <param name="repId">The rep identifier.</param>
        /// <param name="repType">Type of the rep.</param>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <returns></returns>
        public List <UPCRMRep> ChildrenOfGroupWithIdWithTypeRecursive(string repId, UPCRMRepType repType, bool recursive)
        {
            var rep = this.repDictionary.ValueOrDefault(repId);

            return(rep != null?this.ChildrenOfInternalGroupWithTypeRecursive(rep, repType, recursive) : null);
        }
        /// <summary>
        /// Reps the group with identifier has children of type recursive.
        /// </summary>
        /// <param name="repId">The rep identifier.</param>
        /// <param name="repType">Type of the rep.</param>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <returns></returns>
        public bool RepGroupWithIdHasChildrenOfTypeRecursive(string repId, UPCRMRepType repType, bool recursive)
        {
            var rep = this.repDictionary.ValueOrDefault(repId);

            return(rep != null && this.InternalRepGroupHasChildrenOfTypeRecursive(rep, repType, recursive));
        }
        /// <summary>
        /// Childrens the of internal group with type recursive.
        /// </summary>
        /// <param name="rep">The rep.</param>
        /// <param name="repType">Type of the rep.</param>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <returns></returns>
        public List <UPCRMRep> ChildrenOfInternalGroupWithTypeRecursive(UPCRMRep rep, UPCRMRepType repType, bool recursive)
        {
            var repChildren = new List <UPCRMRep>();

            foreach (var childrep in rep.RepChildren)
            {
                if (childrep.RepType == repType)
                {
                    repChildren.Add(childrep);
                }

                if (recursive)
                {
                    var childRepArray = this.ChildrenOfInternalGroupWithTypeRecursive(childrep, repType, true);
                    if (childRepArray.Count > 0)
                    {
                        repChildren.AddRange(childRepArray);
                    }
                }
            }

            return(repChildren.Count > 0 ? repChildren : null);
        }
 /// <summary>
 /// Internals the rep group has children of type recursive.
 /// </summary>
 /// <param name="rep">The rep.</param>
 /// <param name="repType">Type of the rep.</param>
 /// <param name="recursive">if set to <c>true</c> [recursive].</param>
 /// <returns></returns>
 public bool InternalRepGroupHasChildrenOfTypeRecursive(UPCRMRep rep, UPCRMRepType repType, bool recursive)
 {
     return(rep.RepChildren?.Any(childrep => (repType.HasFlag(childrep.RepType) || repType == UPCRMRepType.All) ||
                                 (recursive && this.InternalRepGroupHasChildrenOfTypeRecursive(childrep, repType, true))) ?? false);
 }