Example #1
0
        internal List <Field> GetValues()
        {
            // first determine what we have. There are 3 scenarios:
            // -no view is active
            // -a view is showing
            // -a detail form is showing

            // then we need to figure out what the best way is to get the item values
            // filter uniquely
            // direct/indirect fields

            // no view is active
            if (_avi == null)
            {
                return(null);
            }

            // the view can be empty, or not support getting of data (like the Document view).
            if (_itemName == null)
            {
                return(null);
            }

            List <Field> retval = null;

            // we have a categoryname, so we can figure out the Name field name.
            _nameField = _db.GetNameField(_avi.Category);

            switch (_avi.Type.ToLower())
            {
            case "item detail form":
                // we know the fieldname of this detail form, so we can pass in its XML and find out what fields are showing.
                // That is, if we can find out a way which form is showing...which we can't.|
                // okay never mind then
                return(null);

            default:
                // a view is showing, create a cursor based on it
                // remember that Commence cannot create a cursor on all types of views.
                ICommenceCursor cur;
                try
                {
                    retval = new List <Field>();
                    cur    = _db.GetCursor(_avi.Name, CmcCursorType.View);  // may fail
                }
                catch (ArgumentException)
                {
                    Field f = new Field(_nameField, string.Empty, _itemName);
                    retval.Add(f);
                    return(retval);
                }
                // when the open view's name has quotes in it, the DDE request to retrieve info on it may fail
                // in that case we get an argument exception in Utils.EnumFromAttributeValue
                // that all gets convoluted, let's just swallow all errors and pretend we do not know that :)
                catch { return(retval); }
                retval = GetValuesFromCursor(cur).ToList();
                break;
            } // switch
            return(retval);
        }