/// <summary>
        /// Initializes a new instance of the <see cref="UPSerialEntryParentInfoPanelCell"/> class.
        /// </summary>
        /// <param name="fieldControlTab">The field control tab.</param>
        /// <param name="resultRow">The result row.</param>
        public UPSerialEntryParentInfoPanelCell(FieldControlTab fieldControlTab, UPCRMResultRow resultRow)
        {
            int           numberOfFields = fieldControlTab.NumberOfFields;
            List <string> fields         = new List <string>();

            if (!string.IsNullOrEmpty(fieldControlTab.Label))
            {
                fields.Add(fieldControlTab.Label);
            }

            for (int index = 0; index < numberOfFields; index++)
            {
                UPConfigFieldControlField field = fieldControlTab.FieldAtIndex(index);
                if (index == 0)
                {
                    IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
                    this.ImageName = configStore.InfoAreaConfigById(field.InfoAreaId).ImageName;
                }

                int    offset = 0;
                string value  = resultRow.FormattedFieldValueAtIndex(index, offset, fieldControlTab);
                index += offset;
                if (!string.IsNullOrEmpty(value))
                {
                    fields.Add(value);
                }
            }

            this.FieldValues = fields;
        }
        private void ApplySubTitleFromResultRow(UPCRMResultRow resultRow)
        {
            Dictionary <string, UPConfigFieldControlField> fieldMapping = this.detailsControl.FunctionNames();
            UPConfigFieldControlField fieldControl = fieldMapping.ValueOrDefault("OrganizerHeaderSubLabel");

            if (fieldControl != null)
            {
                ((DetailOrganizerModelController)this.ParentOrganizerModelController)
                .SetRecordTitleForOrganizerHeader(
                    resultRow.FormattedFieldValueAtIndex(fieldControl.TabIndependentFieldIndex, null,
                                                         this.detailsControl));
            }
        }
        /// <summary>
        /// The document data for result row.
        /// </summary>
        /// <param name="resultRow">
        /// The result row.
        /// </param>
        /// <returns>
        /// The <see cref="DocumentData"/>.
        /// </returns>
        public DocumentData DocumentDataForResultRow(UPCRMResultRow resultRow)
        {
            var tab    = this.FieldControl.TabAtIndex(0);
            var title  = this.ResultIndexOfTitle >= 0 ? resultRow.RawValueAtIndex(this.ResultIndexOfTitle) : null;
            var length = this.ResultIndexOfLength >= 0
                             ? resultRow.RawValueAtIndex(this.ResultIndexOfLength).ToUInt64()
                             : 0;
            var dateString = this.ResultIndexOfDate >= 0 ? resultRow.RawValueAtIndex(this.ResultIndexOfDate) : null;
            var mimeType   = this.ResultIndexOfMimeType >= 0
                                  ? resultRow.RawValueAtIndex(this.ResultIndexOfMimeType)
                                  : null;
            var updDateString = this.ResultIndexOfUpdDate >= 0
                                       ? resultRow.RawValueAtIndex(this.ResultIndexOfUpdDate)
                                       : null;
            var updTimeString = this.ResultIndexOfUpdTime >= 0
                                       ? resultRow.RawValueAtIndex(this.ResultIndexOfUpdTime)
                                       : null;
            var displayText = this.ResultIndexOfDisplayText >= 0
                                     ? resultRow.FormattedFieldValueAtIndex(this.ResultIndexOfDisplayText, null, tab)
                                     : null;
            var displayDateString = this.ResultIndexOfDisplayDate >= 0
                                           ? resultRow.FormattedFieldValueAtIndex(this.ResultIndexOfDisplayDate, null, tab)
                                           : null;
            DateTime?documentDate = null;

            if (!string.IsNullOrEmpty(dateString))
            {
                documentDate      = dateString.DateFromCrmValue();
                displayDateString = DateExtensions.LocalizedFormattedDate(documentDate);
            }

            DateTime?updateDate = null;

            if (!string.IsNullOrEmpty(updDateString))
            {
                updateDate = updDateString.DateTimeFromCrmValue();
            }

            string recordIdentification;

            if (resultRow.NumberOfRecordIds() > this.RecordIndex)
            {
                recordIdentification = resultRow.RecordIdentificationAtIndex(this.RecordIndex);
            }
            else
            {
                recordIdentification = resultRow.RootRecordIdentification;
            }

            string d1RecordId = resultRow.RecordIdentificationForLinkInfoAreaIdLinkId("D1", -1);

            return(new DocumentData(
                       recordIdentification,
                       title,
                       mimeType,
                       documentDate,
                       length,
                       updateDate,
                       displayText,
                       displayDateString,
                       d1RecordId));
        }
Exemple #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();
        }