Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPCRMRecordTile"/> class.
        /// </summary>
        /// <param name="tiles">The tiles.</param>
        /// <param name="viewReference">The view reference.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="menuAction">The menu action.</param>
        /// <exception cref="Exception">
        /// RecordIdentification is null
        /// or
        /// TableCaptionName is null
        /// </exception>
        public UPCRMRecordTile(UPCRMTiles tiles, ViewReference viewReference, Dictionary <string, object> parameters, Menu menuAction)
            : base(tiles, viewReference, parameters, menuAction)
        {
            this.tableCaptionName     = this.ViewReference.ContextValueForKey("tableCaption");
            this.recordIdentification = this.ViewReference.ContextValueForKey("uid");
            string imageMapFilterName           = this.ViewReference.ContextValueForKey("imageMapFilter");
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            if (string.IsNullOrEmpty(this.recordIdentification))
            {
                throw new Exception("RecordIdentification is null");
            }

            if (!string.IsNullOrEmpty(this.tableCaptionName))
            {
                this.tableCaption = configStore.TableCaptionByName(this.tableCaptionName);
            }

            if (this.tableCaption == null)
            {
                if (string.IsNullOrEmpty(this.tableCaptionName))
                {
                    throw new Exception("TableCaptionName is null");
                }
            }

            if (!string.IsNullOrEmpty(imageMapFilterName))
            {
                this.imageFilter = configStore.FilterByName(imageMapFilterName);
                this.imageFilter = this.imageFilter?.FilterByApplyingValueDictionaryDefaults(this.Parameters, true);

                if (this.imageFilter != null)
                {
                    this.catalogAttributes = configStore.CatalogAttributesByFilter(this.imageFilter);
                    if (this.catalogAttributes != null)
                    {
                        this.crmQuery?.AddCrmFields(new List <UPCRMField> {
                            this.catalogAttributes.CrmField
                        });
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Explicits the key order by catalog attribute code order.
        /// </summary>
        /// <param name="catalogAttributes">The catalog attributes.</param>
        /// <param name="codeOrder">The code order.</param>
        /// <returns></returns>
        public List <string> ExplicitKeyOrderByCatalogAttributeCodeOrder(UPConfigCatalogAttributes catalogAttributes, List <string> codeOrder)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>(codeOrder.Count);

            foreach (string v in codeOrder)
            {
                dict.Add(v, v);
            }

            List <string> resultArray = catalogAttributes.ValueArray.Where(v => dict.ContainsKey(v.RawValue)).Select(v => v.RawValue).ToList();

            if (resultArray.Count < codeOrder.Count)
            {
                dict = new Dictionary <string, string>(codeOrder.Count);
                foreach (string v in resultArray)
                {
                    dict[v] = v;
                }

                resultArray.AddRange(codeOrder.Where(v => dict.ContainsKey(v)));
            }

            return(resultArray);
        }
        private UPMGroup BuildGroup(UPMGroup group)
        {
            Dictionary <string, string> infoAreaImageFileNames = new Dictionary <string, string>();
            IConfigurationUnitStore     configStore            = ConfigurationUnitStore.DefaultStore;
            UPConfigExpand repExpand = configStore.ExpandByName("ID");

            this.linkParticipantsViewReference = null;

            if (!string.IsNullOrEmpty(this.linkParticipantsName))
            {
                SearchAndList searchAndList = configStore.SearchAndListByName(this.linkParticipantsName);
                Menu          menu          = searchAndList != null?configStore.MenuByName(searchAndList.DefaultAction) : null;

                this.linkParticipantsViewReference = menu?.ViewReference;
            }

            if (this.acceptanceCatalogAttributes == null && this.recordParticipants.AcceptanceField != null)
            {
                this.acceptanceCatalogAttributes = configStore.CatalogAttributesForInfoAreaIdFieldId(this.recordParticipants.AcceptanceField.InfoAreaId, this.recordParticipants.AcceptanceField.FieldId);
            }

            foreach (UPCRMParticipant participant in this.recordParticipants.Participants)
            {
                bool           isRepParticipant = participant is UPCRMRepParticipant;
                IIdentifier    identifier       = StringIdentifier.IdentifierWithStringId(participant.Key);
                UPMListRow     listRow          = new UPMListRow(identifier);
                UPMStringField nameField        = new UPMStringField(StringIdentifier.IdentifierWithStringId("name"));
                nameField.StringValue = participant.Name;
                listRow.AddField(nameField);
                UPMStringField acceptanceField = new UPMStringField(StringIdentifier.IdentifierWithStringId("acceptance"));
                if (!isRepParticipant || this.recordParticipants.HasRepAcceptance)
                {
                    acceptanceField.StringValue = participant.AcceptanceDisplayText;
                    UPConfigCatalogValueAttributes configCatalogValueAttributes = this.acceptanceCatalogAttributes?.ValuesByCode[Convert.ToInt32(participant.AcceptanceText)];
                    string colorString = configCatalogValueAttributes?.ColorKey;
                    if (!string.IsNullOrEmpty(colorString))
                    {
                        listRow.RowColor = AureaColor.ColorWithString(colorString);
                    }
                }
                else
                {
                    acceptanceField.StringValue = string.Empty;
                }

                listRow.AddField(acceptanceField);
                UPMStringField requirementField = new UPMStringField(StringIdentifier.IdentifierWithStringId("requirement"));
                requirementField.StringValue = participant.RequirementDisplayText;
                listRow.AddField(requirementField);
                if (isRepParticipant)
                {
                    // listRow.Icon = UIImage.UpImageWithFileName(repExpand.ImageName);     // CRM-5007
                    listRow.RowAction = null;
                }
                else
                {
                    UPCRMLinkParticipant linkParticipant = (UPCRMLinkParticipant)participant;
                    string _infoAreaId = linkParticipant.LinkRecordIdentification.InfoAreaId();
                    string imageName   = infoAreaImageFileNames.ValueOrDefault(_infoAreaId);
                    if (imageName == null)
                    {
                        UPConfigExpand expand = configStore.ExpandByName(_infoAreaId);
                        imageName = expand.ImageName ?? string.Empty;

                        infoAreaImageFileNames.SetObjectForKey(imageName, _infoAreaId);
                    }

                    // listRow.Icon = UIImage.UpImageWithFileName(imageName);       // CRM-5007
                    listRow.OnlineData = !UPCRMDataStore.DefaultStore.RecordExistsOffline(linkParticipant.LinkRecordIdentification);

                    if (this.linkParticipantsViewReference != null)
                    {
                        UPMAction switchToOrganizerAction = new UPMAction(null);
                        switchToOrganizerAction.IconName = "arrow.png";
                        switchToOrganizerAction.SetTargetAction(this, this.SwitchToOrganizerForLinkParticipant);
                        listRow.RowAction = switchToOrganizerAction;
                    }
                }

                group.AddChild(listRow);
            }

            return(group);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResultRowCalendarItem" /> class.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <param name="resultContext">The result context.</param>
        /// <param name="identifier">The identifier.</param>
        /// <param name="tableCaption">The table caption.</param>
        /// <param name="tableCaptionResultFieldMap">The table caption result field map.</param>
        /// <param name="attributes">The attributes.</param>
        /// <param name="color">The color.</param>
        /// <exception cref="Exception">StartDate is null</exception>
        public ResultRowCalendarItem(UPCRMResultRow row,
                                     UPCoreMappingResultContext resultContext,
                                     IIdentifier identifier,
                                     UPConfigTableCaption tableCaption, List <UPContainerFieldMetaInfo> tableCaptionResultFieldMap,
                                     UPConfigCatalogAttributes attributes, AureaColor color)
            : base(identifier)
        {
            this.ResultContext = resultContext;
            var    fieldMapping    = this.ResultContext.FieldControl.FunctionNames();
            var    dict            = this.ResultContext.FieldControl.FunctionNames(row);
            string startDateString = dict.ValueOrDefault("Date") as string;
            string startTimeString = dict.ValueOrDefault("Time") as string;
            string endDateString   = dict.ValueOrDefault("EndDate") as string;
            string endTimeString   = dict.ValueOrDefault("EndTime") as string;

            UPConfigFieldControlField personLabelControlField = fieldMapping.ValueOrDefault("PersonLabel");

            if (personLabelControlField != null)
            {
                this.PersonLabelField = UPMStringField.StringFieldWithIdentifierValue(
                    new FieldIdentifier(row.RootRecordIdentification, personLabelControlField.Field.FieldIdentification),
                    row.FormattedFieldValueAtIndex(personLabelControlField.TabIndependentFieldIndex, null, this.ResultContext.FieldControl));
            }

            UPConfigFieldControlField companyLabelControlField = fieldMapping.ValueOrDefault("CompanyLabel");

            if (companyLabelControlField != null)
            {
                this.CompanyLabelField = UPMStringField.StringFieldWithIdentifierValue(
                    new FieldIdentifier(row.RootRecordIdentification, companyLabelControlField.Field.FieldIdentification),
                    row.FormattedFieldValueAtIndex(companyLabelControlField.TabIndependentFieldIndex, null, this.ResultContext.FieldControl));
            }

            UPConfigFieldControlField field = fieldMapping.ValueOrDefault("Status");
            string status = dict.ValueOrDefault("Status") as string;

            if (field != null)
            {
                this.StatusLabelField = UPMStringField.StringFieldWithIdentifierValue(
                    new FieldIdentifier(row.RootRecordIdentification, field.Field.FieldIdentification),
                    field.Field.ValueForRawValueOptions(status, 0));
            }

            string repLabel = dict.ValueOrDefault("RepLabel") as string;

            if (string.IsNullOrEmpty(repLabel))
            {
                string repId = dict.ValueOrDefault("RepId") as string;
                if (!string.IsNullOrEmpty(repId))
                {
                    repLabel = UPCRMDataStore.DefaultStore.Reps.RepWithId(repId).RepName;
                }
            }

            this.RepLabelField = UPMStringField.StringFieldWithIdentifierValue(StringIdentifier.IdentifierWithStringId("rep"), repLabel);
            int iType = Convert.ToInt32(dict.ValueOrDefault("Type"));

            this.Type             = (UPCalendarItemType)iType;
            this.StartDate        = StringExtensions.DateFromStrings(startDateString, startTimeString);
            this.EndDate          = StringExtensions.DateFromStrings(endDateString, endTimeString);
            this.Identification   = identifier.IdentifierAsString;
            this.Color            = color;
            this.RowColor         = this.Color;
            this.CrmResultRow     = row;
            this.IPadCalendarItem = null;
            this.HasTime          = !string.IsNullOrEmpty(startTimeString);
            this.HasEndTime       = !string.IsNullOrEmpty(endTimeString);

            UPConfigCatalogValueAttributes temp = attributes?.ValuesByCode[iType];

            if (temp != null)
            {
                if (this.Color == null)
                {
                    string colorString = temp.ColorKey;
                    if (string.IsNullOrEmpty(colorString))
                    {
                        this.Color = AureaColor.ColorWithString(colorString);
                    }
                }

                this.ImageName = temp.ImageName;
            }

            if (tableCaption != null)
            {
                this.Subject = tableCaption.TableCaptionForResultRow(row, tableCaptionResultFieldMap);
            }
            else
            {
                this.Subject = dict.ValueOrDefault("Subject") as string;
            }

            if (this.StartDate == DateTime.MinValue)
            {
                throw new Exception("StartDate is null");
            }

            if (this.EndDate == DateTime.MinValue)
            {
                this.EndDate = this.StartDate;
            }

            if (this.Type < UPCalendarItemType.Color0 || this.Type >= UPCalendarItemType.ColorCount)
            {
                this.Type = UPCalendarItemType.Color0;
            }

            //this.AllDay = this.DetermineIsAllDay();
        }
Example #5
0
        UPMEditField CreateDependEditFieldWithParticipantIdentifierCatalogEditGroup(UPMIdentifier participantIdentifier, UPCatalog catalog, UPMGroup editGroup)
        {
            UPCRMField field;

            if (catalog == this.ParticipantsControl.RequirementCatalog)
            {
                field = this.ParticipantsControl.RequirementField;
            }
            else if (catalog == this.ParticipantsControl.AcceptanceCatalog)
            {
                field = this.ParticipantsControl.AcceptanceField;
            }

            UPMParticipantCatalogEditField editField = new UPMParticipantCatalogEditField(UPMStringIdentifier.IdentifierWithStringId(NSString.StringWithFormat("dependField_%@_%@_%ld", participantIdentifier.Description, field.InfoAreaId, (long)field.FieldId)));

            editField.GroupModelController = this;
            editField.Group = editGroup;
            if (catalog != null)
            {
                ArrayList                 possibleValues = catalog.Values;
                ArrayList                 explicitKeyOrder;
                NSDictionary              possibleValuesAsString      = catalog ? catalog.TextValuesForFieldValues() : null;
                UPConfigurationUnitStore  configStore                 = UPConfigurationUnitStore.DefaultStore();
                UPConfigCatalogAttributes acceptanceCatalogAttributes = configStore.CatalogAttributesForInfoAreaIdFieldId(field.InfoAreaId, field.FieldId);
                possibleValues.EnumerateObjectsUsingBlock(delegate(object obj, uint idx, bool stop)
                {
                    UPMCatalogPossibleValue possibleValue = new UPMCatalogPossibleValue();
                    UPMStringField valueField             = new UPMStringField(UPMStringIdentifier.IdentifierWithStringId("x"));
                    UPCatalogValue catalogValue           = (UPCatalogValue)obj;
                    valueField.StringValue        = catalogValue.Text;
                    possibleValue.TitleLabelField = valueField;
                    UPConfigCatalogValueAttributes configCatalogValueAttributes = acceptanceCatalogAttributes.ValuesByCode().ObjectForKey(NSNumber.NumberWithInt(catalogValue.CodeKey.IntValue));
                    if (configCatalogValueAttributes)
                    {
                        string colorString = configCatalogValueAttributes.ColorKey();
                        if (colorString)
                        {
                            possibleValue.IndicatorColor = UPColor.ColorWithString(colorString);
                        }

                        possibleValue.ImageString = configCatalogValueAttributes.ImageName();
                    }

                    editField.AddPossibleValueForKey(possibleValue, catalogValue.CodeKey);
                });
                if (((string)possibleValuesAsString.ObjectForKey("0")).Length == 0)
                {
                    editField.NullValueKey = "0";
                }

                if (catalog != null && acceptanceCatalogAttributes != null && !UPConfigurationUnitStore.DefaultStore().ConfigValueIsSet("FixedCatalog.SortByAttributeFilter"))
                {
                    explicitKeyOrder = this.ExplicitKeyOrderByCatalogAttributeCodeOrder(acceptanceCatalogAttributes, catalog.ExplicitKeyOrderByCodeEmptyValueIncludeHidden(false, false));
                }
                else if (catalog != null && UPConfigurationUnitStore.DefaultStore().ConfigValueIsSet("FixedCatalog.SortByCode"))
                {
                    explicitKeyOrder = catalog.ExplicitKeyOrderByCodeEmptyValueIncludeHidden(false, false);
                }
                else
                {
                    explicitKeyOrder = catalog.ExplicitKeyOrderEmptyValueIncludeHidden(false, false);
                }

                if (explicitKeyOrder != null)
                {
                    editField.ExplicitKeyOrder = explicitKeyOrder;
                }

                editField.ContinuousUpdate = true;
            }

            return(editField);
        }