Esempio n. 1
0
 internal ActiveItem()
 {
     _db           = new CommenceDatabase();
     _avi          = _db.GetActiveViewInfo();
     clarifyStatus = _db.ClarifyItemNames();
     _db.ClarifyItemNames("false");
     _itemName = _db.GetActiveItemName();
     _db.ClarifyItemNames(clarifyStatus);
 }
Esempio n. 2
0
        private IEnumerable <Field> GetValuesFromCursor(ICommenceCursor cur)
        {
            IEnumerable <Field>      retval            = new List <Field>(); // a cursor cannot have no fields, so we should be safe.
            ColumnParser             cp                = new ColumnParser(cur);
            IList <ColumnDefinition> columnDefinitions = cp.ParseColumns();

            _db.ClarifyItemNames("true");
            _itemName = _db.GetActiveItemName(); // also marks the item for us

            IList <Field> fields = new List <Field> {
                new Field {
                    Name  = _nameField,
                    Value = _itemName,
                    Label = columnDefinitions
                            .Where(w => !w.IsConnection)
                            .SingleOrDefault(s => s.FieldName.Equals(_nameField))?.ColumnLabel
                }
            };

            // if the name field isn't in the view the view label will be empty,
            // in that casechange it to fieldname instead
            // note that this will actually return more information than is showing in Commence
            if (string.IsNullOrEmpty(fields[0].Label))
            {
                fields[0].Label = _nameField;
            }

            // get a list of all the direct fields except the name field
            IEnumerable <ColumnDefinition> directFields = columnDefinitions
                                                          .Where(w => !w.IsConnection && w.FieldName != _nameField)
                                                          .ToArray();
            // get the direct field values using DDE
            IEnumerable <Field> directFieldValues = GetDirectFieldValues(directFields);

            retval = fields.Concat(directFieldValues);

            // get the indirect values
            IEnumerable <RelatedColumn> relatedColumns = columnDefinitions
                                                         .Where(w => w.IsConnection)
                                                         .Select(s => new RelatedColumn(s.Connection,
                                                                                        s.Category,
                                                                                        s.FieldName,
                                                                                        RelatedColumnType.ConnectedField,
                                                                                        s.QualifiedConnection + ' ' + s.FieldName)) // very dirty trick!!!!!!
                                                         .ToArray();
            IEnumerable <Field> connectedFieldValues = GetConnectedFieldValues(relatedColumns);

            retval = retval.Concat(connectedFieldValues);
            _db.ClarifyItemNames(clarifyStatus); // restore original setting
            return(retval);
        } // method