Beispiel #1
0
        private UPMGroup GroupFromRow(UPCRMResultRow resultRow)
        {
            UPMDocumentsGroup docGroup             = null;
            string            recordIdentification = resultRow.RootRecordIdentification;
            int             fieldCount             = this.TabConfig.NumberOfFields;
            DocumentManager documentManager        = new DocumentManager();

            for (int j = 0; j < fieldCount; j++)
            {
                UPConfigFieldControlField fieldConfig = this.TabConfig.FieldAtIndex(j);
                string documentKey = resultRow.ValueAtIndex(fieldConfig.TabIndependentFieldIndex);
                if (!string.IsNullOrEmpty(documentKey))
                {
                    DocumentData documentData = documentManager.DocumentForKey(documentKey);
                    if (documentData != null)
                    {
                        if (docGroup == null)
                        {
                            docGroup           = new UPMDocumentsGroup(this.TabIdentifierForRecordIdentification(recordIdentification));
                            docGroup.LabelText = this.TabLabel;
                        }

                        UPMDocument document = new UPMDocument(new RecordIdentifier(recordIdentification), fieldConfig.Label,
                                                               documentData.DateString, documentData.SizeString, null, documentData.Url, documentData.Title,
                                                               documentData.ServerUpdateDate, documentData.DisplayText, null);

                        docGroup.AddField(document);
                    }
                }
            }

            this.ControllerState = docGroup != null ? GroupModelControllerState.Finished : GroupModelControllerState.Empty;
            this.Group           = docGroup;
            return(docGroup);
        }
Beispiel #2
0
        private UPMGroup GroupFromResult(UPCRMResult result)
        {
            UPMDocumentsGroup docGroup = new UPMDocumentsGroup(this.TabIdentifierForRecordIdentification(this.RecordIdentification));

            docGroup.LabelText = this.TabLabel;
            int location = this.TabConfig.Type.IndexOf(".");

            if (location != -1)
            {
                string style = this.TabConfig.Type.Substring(location + 1);
                if (style.StartsWith("IMG"))
                {
                    docGroup.Style = UPMDocumentsGroupStyle.Image;
                }
                else if (style.StartsWith("NOIMG"))
                {
                    docGroup.Style = UPMDocumentsGroupStyle.NoImages;
                }
                else
                {
                    Logger.LogWarn($"Unknown style for DOC group: {style}");
                }
            }

            if (this.FillGroupWithLocalDocumentsResult(docGroup, result))
            {
                this.Group           = docGroup;
                this.ControllerState = GroupModelControllerState.Finished;
                return(docGroup);
            }

            this.Group           = null;
            this.ControllerState = GroupModelControllerState.Empty;
            return(null);
        }
Beispiel #3
0
        private bool FillGroupWithLocalDocumentsResult(UPMDocumentsGroup group, UPCRMResult result)
        {
            if (this._sendEmailFieldgroup != null)
            {
                this._linkedRecordId = this.RecordIdentification;
            }

            int count = result.RowCount;

            if (count == 0)
            {
                return(false);
            }

            if (this.MaxResults > 0 && count > this.MaxResults)
            {
                count = this.MaxResults;
            }

            DocumentInfoAreaManager documentInfoAreaManager;

            if (this.fieldControl.InfoAreaId == "D3" && this.TabConfig.Type.StartsWith("D1"))
            {
                documentInfoAreaManager = new DocumentInfoAreaManager(this.fieldControl.InfoAreaId, this.fieldControl, 1, null);
            }
            else
            {
                documentInfoAreaManager = new DocumentInfoAreaManager(this.fieldControl.InfoAreaId, this.fieldControl, null);
            }

            for (int i = 0; i < count; i++)
            {
                UPCRMResultRow resultRow    = (UPCRMResultRow)result.ResultRowAtIndex(i);
                DocumentData   documentData = documentInfoAreaManager.DocumentDataForResultRow(resultRow);
                UPMDocument    document     = new UPMDocument(documentData);
                if (this._sendEmailFieldgroup != null)
                {
                    document.LinkedRecordId  = this._linkedRecordId;
                    document.EmailFieldgroup = this._sendEmailFieldgroup;
                }

                if (this.IsDocumentIncludedInGroup(document, group))
                {
                    group.AddField(document);
                }
            }

            if (group.Fields.Count == 0)
            {
                return(false);
            }

            return(true);
        }
Beispiel #4
0
        private bool IsDocumentIncludedInGroup(UPMDocument document, UPMDocumentsGroup group)
        {
            var imageExtensions = new List <string> {
                ".jpg", ".jpeg", ".png", ".gif", ".tiff", ".tif", ".bmp"
            };

            switch (group.Style)
            {
            case UPMDocumentsGroupStyle.Image:
            case UPMDocumentsGroupStyle.NoImages:
                bool   withImage  = group.Style == UPMDocumentsGroupStyle.Image;
                string lowerFname = document.LocalFileName.ToLower();
                return(imageExtensions.Any(extension => lowerFname.EndsWith(extension)) ? withImage : !withImage);

            default:
                return(true);
            }
        }
 /// <summary>
 /// Adds the group.
 /// </summary>
 /// <param name="group">The group.</param>
 public void AddGroup(UPMDocumentsGroup group)
 {
     this.HasDocuments = group.Children.Count > 0;
     this.fields.AddRange(group.Fields);     // Verify this
 }
Beispiel #6
0
        private void LoadData(UPMObjectivesPage objectivesPage)
        {
            int itemCounter    = 0;
            int sectionCounter = 0;

            foreach (UPObjectivesGroup group in this.objectivesGroupArray)
            {
                UPMObjectivesSection section = this.CreateSectionIdentfier(group.Label, StringIdentifier.IdentifierWithStringId(group.GroupKey));
                foreach (UPObjectivesItem item in group.Items)
                {
                    UPMObjective mobjective = this.CreateObjectiveIdentfier(item, StringIdentifier.IdentifierWithStringId($"ObjectiveItem_{itemCounter}"));
                    if (item.Documents != null)
                    {
                        UPMDocumentsGroup documentGroup = new UPMDocumentsGroup(StringIdentifier.IdentifierWithStringId($"documentgroup{itemCounter}"));
                        foreach (DocumentData document in item.Documents)
                        {
                            UPMDocument documentModel = new UPMDocument(document);
                            documentGroup.AddChild(documentModel);
                        }

                        mobjective.AddGroup(documentGroup);
                    }

                    mobjective.ObjectiveItem = item;
                    Dictionary <string, UPEditFieldContext> itemEditFields = new Dictionary <string, UPEditFieldContext>();
                    for (int additionalFieldIndex = 0; additionalFieldIndex < item.AdditionalFields.Count; additionalFieldIndex++)
                    {
                        UPConfigFieldControlField field           = item.AdditionalFields[additionalFieldIndex];
                        RecordIdentifier          fieldIdentifier = new RecordIdentifier(field.Identification);
                        UPEditFieldContext        fieldContext    = null;
                        FieldAttributes           attributes      = field.Attributes;
                        if (attributes != null && attributes.Hide)
                        {
                            fieldContext = UPEditFieldContext.HiddenFieldFor(field, fieldIdentifier, item.Values[additionalFieldIndex]);
                        }
                        else if (attributes != null && attributes.ReadOnly)
                        {
                            fieldContext = UPEditFieldContext.ReadonlyFieldFor(field, fieldIdentifier, item.Values[additionalFieldIndex]);
                        }
                        else
                        {
                            fieldContext = UPEditFieldContext.FieldContextFor(field, fieldIdentifier, item.Values[additionalFieldIndex], (List <UPEditFieldContext>)null);
                        }

                        if (fieldContext?.Field != null)
                        {
                            string fieldIdentification = this.FieldIdentificationSectionCounterItemCounter(field.Field, sectionCounter, itemCounter);
                            this.editPageContext.EditFields.SetObjectForKey(fieldContext, fieldIdentification);
                            itemEditFields.SetObjectForKey(fieldContext, fieldIdentification);
                            if (fieldContext.EditField != null)
                            {
                                fieldContext.EditField.EditFieldsContext = this.editPageContext;
                                mobjective.AddField(fieldContext.EditField);
                            }
                            else
                            {
                                mobjective.AddField(fieldContext.Field);
                            }
                        }
                    }

                    this.HandleDependentFieldsSectionCounterItemCounter(itemEditFields, sectionCounter, itemCounter);
                    if (item.ButtonActions.Count > 0)
                    {
                        List <UPMOrganizerAction> buttonActions = new List <UPMOrganizerAction>();
                        foreach (UPConfigButton button in item.ButtonActions)
                        {
                            StringIdentifier   fieldIdentifier = StringIdentifier.IdentifierWithStringId("button");
                            UPMOrganizerAction action          = new UPMOrganizerAction(fieldIdentifier);
                            //action.SetTargetAction(this.ParentOrganizerModelController, PerformObjectivesAction);
                            action.ViewReference = button.ViewReference.ViewReferenceWith(item.Record.RecordIdentification);
                            action.LabelText     = button.Label;
                            buttonActions.Add(action);
                        }

                        mobjective.Actions = buttonActions;
                    }

                    section.AddChild(mobjective);
                    itemCounter++;
                }

                if (section.Children.Count > 0)
                {
                    objectivesPage.AddChild(section);
                }
            }

            if (objectivesPage.Children.Count == 0)
            {
                UPMMessageStatus messageStatus = new UPMMessageStatus(StringIdentifier.IdentifierWithStringId("messageIdentifier"));
                UPMStringField   messageField  = new UPMStringField(StringIdentifier.IdentifierWithStringId("statusFieldIdentifier"));
                messageField.FieldValue          = LocalizedString.Localize(LocalizationKeys.TextGroupBasic, LocalizationKeys.KeyBasicNoObjectives);
                messageStatus.DetailMessageField = messageField;
                objectivesPage.Status            = messageStatus;
            }
        }