Exemple #1
0
        public object this[IQColumn column]
        {
            get
            {
                // Get field location with column index
                var qField     = new QField(column.ColumnId);
                var fieldIndex = this._fields.IndexOf(qField);

                if (fieldIndex == -1)
                {
                    //make null field
                    CreateNewField(column.ColumnId, null, false);
                    fieldIndex = this._fields.IndexOf(qField);
                }
                // Return field with column index
                return(this._fields[fieldIndex].Value);
            }

            set
            {
                // Get field location with column index
                var fieldIndex = this._fields.IndexOf(new QField(column.ColumnId));

                if (fieldIndex > -1)
                {
                    SetExistingField(column.ColumnId, fieldIndex, value);
                }
                else
                {
                    CreateNewField(column.ColumnId, value, false);
                }
            }
        }
Exemple #2
0
        private void LoadColumns(XPathNavigator xml)
        {
            Columns.Clear();
            var columnNodes = xml.Select("/qdbapi/table/fields/field");

            foreach (XPathNavigator columnNode in columnNodes)
            {
                var columnId = int.Parse(columnNode.GetAttribute("id", String.Empty));
                var type     =
                    (FieldType)Enum.Parse(typeof(FieldType), columnNode.GetAttribute("field_type", String.Empty), true);
                var  label   = columnNode.SelectSingleNode("label").Value;
                bool hidden  = false;
                var  hidNode = columnNode.SelectSingleNode("appears_by_default");
                if (hidNode != null && hidNode.Value == "0")
                {
                    hidden = true;
                }
                bool     virt   = columnNode.GetAttribute("mode", String.Empty) == "virtual";
                bool     lookup = columnNode.GetAttribute("mode", String.Empty) == "lookup";
                IQColumn col    = ColumnFactory.CreateInstace(columnId, label, type, virt, lookup, hidden);
                foreach (XPathNavigator choicenode in columnNode.Select("choices/choice"))
                {
                    object value;
                    switch (type)
                    {
                    case FieldType.rating:
                        value = Int32.Parse(choicenode.Value);
                        break;

                    default:
                        value = choicenode.Value;
                        break;
                    }
                    ((IQColumn_int)col).AddChoice(value);
                }
                Dictionary <string, int> colComposites = ((IQColumn_int)col).GetComposites();
                foreach (XPathNavigator compositenode in columnNode.Select("compositeFields/compositeField"))
                {
                    colComposites.Add(compositenode.GetAttribute("key", String.Empty), Int32.Parse(compositenode.GetAttribute("id", String.Empty)));
                }
                Columns.Add(col);
            }
            var keyFidNode = xml.SelectSingleNode("/qdbapi/table/original/key_fid");

            if (keyFidNode != null)
            {
                KeyFID = keyFidNode.ValueAsInt;
            }
            else
            {
                KeyFID = Columns.Find(c => c.ColumnType == FieldType.recordid).ColumnId;
            }
            KeyCIdx = Columns.FindIndex(c => c.ColumnId == KeyFID);
        }
 // Methods
 public bool Equals(IQColumn column)
 {
     if (ReferenceEquals(null, column))
     {
         return(false);
     }
     if (ReferenceEquals(this, column))
     {
         return(true);
     }
     return(Equals(column.ColumnName, ColumnName));
 }
 internal QField(int fieldId, object value, FieldType type, IQRecord record, IQColumn column,  bool QBinternal)
 {
     FieldId = fieldId;
     Type = type;
     Record = record; // needs to be before Value.
     Column = column;
     if (QBinternal)
     {
         QBValue = (string)value;
     }
     else
     {
         Value = value;
     }
 }
Exemple #5
0
 internal QField(int fieldId, object value, FieldType type, IQRecord record, IQColumn column, bool QBinternal)
 {
     FieldId = fieldId;
     Type    = type;
     Record  = record; // needs to be before Value.
     Column  = column;
     if (QBinternal)
     {
         QBValue = (string)value;
     }
     else
     {
         Value = value;
     }
     if (type == FieldType.text && value != null)
     {
         UncleanText = CSVUncleanRegEx.IsMatch((string)value);
     }
     else
     {
         UncleanText = false;
     }
 }
 // Constructors
 internal QField(int fieldId, object value, FieldType type, IQRecord record, IQColumn column)
     : this(fieldId, value, type, record, column, false)
 {
 }
Exemple #7
0
 // Constructors
 internal QField(int fieldId, object value, FieldType type, IQRecord record, IQColumn column) : this(fieldId, value, type, record, column, false)
 {
 }
        private void LoadColumns(XElement xml)
        {
            Columns.Clear();
            var columnNodes = xml.Element("table").Element("fields").Elements("field");

            foreach (XElement columnNode in columnNodes)
            {
                int       columnId = int.Parse(columnNode.Attribute("id").Value);
                FieldType type     =
                    (FieldType)Enum.Parse(typeof(FieldType), columnNode.Attribute("field_type").Value, true);
                string   label   = columnNode.Element("label").Value;
                bool     hidden  = false;
                XElement hidNode = columnNode.Element("appears_by_default");
                if (hidNode != null && hidNode.Value == "0")
                {
                    hidden = true;
                }
                bool canAddChoices = columnNode.Element("allow_new_choices")?.Value == "1";
                bool virt = false, lookup = false, summary = false;
                if (columnNode.Attribute("mode") != null)
                {
                    string mode = columnNode.Attribute("mode").Value;
                    virt    = mode == "virtual";
                    lookup  = mode == "lookup";
                    summary = mode == "summary";
                }

                bool     allowHTML = columnNode.Element("allowHTML")?.Value == "1";
                IQColumn col       = ColumnFactory.CreateInstance(columnId, label, type, virt, lookup, summary, hidden, canAddChoices);
                if (columnNode.Element("choices") != null)
                {
                    foreach (XElement choicenode in columnNode.Element("choices").Elements("choice"))
                    {
                        object value;
                        switch (type)
                        {
                        case FieldType.rating:
                            value = Int32.Parse(choicenode.Value);
                            break;

                        default:
                            value = choicenode.Value;
                            break;
                        }
                        ((IQColumn_int)col).AddChoice(value, true);
                    }
                }
                Dictionary <string, int> colComposites = ((IQColumn_int)col).GetComposites();
                if (columnNode.Element("compositeFields") != null)
                {
                    foreach (XElement compositenode in columnNode.Element("compositeFields").Elements("compositeField"))
                    {
                        colComposites.Add(compositenode.Attribute("key").Value,
                                          Int32.Parse(compositenode.Attribute("id").Value));
                    }
                }
                Columns.Add(col);
            }
            var keyFidNode = xml.Element("table").Element("original").Element("key_fid");

            KeyFID = keyFidNode != null?Int32.Parse(keyFidNode.Value) : Columns.Find(c => c.ColumnType == FieldType.recordid).ColumnId;

            KeyCIdx = Columns.FindIndex(c => c.ColumnId == KeyFID);
        }
 // Methods
 public bool Equals(IQColumn column)
 {
     if (ReferenceEquals(null, column)) return false;
     if (ReferenceEquals(this, column)) return true;
     return Equals(column.ColumnName, ColumnName);
 }