示例#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);
        }
示例#2
0
        private ICommenceCursor GetCategoryCursorFieldsOnly(ICommenceDatabase db, string categoryName, CmcOptionFlags flags)
        {
            ICommenceCursor cur = db.GetCursor(categoryName, CmcCursorType.Category, flags);

            string[] fieldNames = db.GetFieldNames(categoryName).ToArray();
            cur.Columns.AddDirectColumns(fieldNames);
            cur.Columns.Apply();
            return(cur);
        }
示例#3
0
        private ICommenceCursor GetCategoryCursorAllFieldsAndConnections(ICommenceDatabase db, string categoryName, CmcOptionFlags flags)
        {
            ICommenceCursor cur = db.GetCursor(categoryName, CmcCursorType.Category, flags);

            string[] fieldNames = db.GetFieldNames(categoryName).ToArray();
            cur.Columns.AddDirectColumns(fieldNames);
            var cons = db.GetConnectionNames(cur.Category);

            foreach (var c in cons)
            {
                //string nameField = db.GetNameField(c.ToCategory);
                //cur.Columns.AddRelatedColumn(c.Name, c.ToCategory, nameField); // this is bad. a related column loses the THID flag
                cur.Columns.AddDirectColumn(c.Name + ' ' + c.ToCategory); // will respect UseThids flag
            }
            cur.Columns.Apply();
            return(cur);
        }
示例#4
0
        internal ICommenceCursor Create(CursorDescriptor cursorParameters)
        {
            ICommenceCursor retval = null;

            if (db == null)
            {
                throw new InvalidOperationException($"Underlying database was closed.");
            }
            retval = db.GetCursor(cursorParameters.CategoryOrView, cursorParameters.CursorType, CmcOptionFlags.UseThids | CmcOptionFlags.IgnoreSyncCondition);
            retval.SetColumns(cursorParameters.Fields.ToArray());
            retval.Columns.Apply();
            for (int i = 0; i < cursorParameters.Filters.Count(); i++)
            {
                ICursorFilterTypeCTCF f = retval.Filters.Create(i + 1, FilterType.ConnectionToCategoryField);
                // we already have the filter object defined, copy them
                foreach (PropertyInfo property in typeof(ICursorFilterTypeCTCF).GetProperties().Where(p => p.CanWrite))
                {
                    property.SetValue(f, property.GetValue(cursorParameters.Filters[i], null), null);
                }
            }
            retval.Filters.Apply();
            retval.MaxFieldSize = cursorParameters.MaxFieldSize;
            return(retval);
        }