public void LoadData(FieldList flds)
        {
            fields = (FieldList)flds.Clone();
            ListViewItem v;

            for (int i = 0; i < fields.Count; i++)
            {
                v = new ListViewItem(fields[i].Name);
                v.SubItems.Add(EPField.TypeString(fields[i].OleDbType));
                v.SubItems.Add(fields[i].DataSize.ToString());
                if (fields[i].Value == null)
                {
                    v.SubItems.Add("");
                }
                else
                {
                    v.SubItems.Add(fields[i].Value.ToString());
                }
                listView1.Items.Add(v);
            }
            if (listView1.Items.Count > 0)
            {
                listView1.Items[0].Selected = true;
            }
        }
        public object Clone()
        {
            DatabaseView obj = new DatabaseView();

            obj.fields   = (FieldList)fields.Clone();
            obj.ViewName = ViewName;
            obj.InUse    = InUse;
            return(obj);
        }
        public object Clone()
        {
            DatabaseTable obj = new DatabaseTable();

            obj.fields    = (FieldList)fields.Clone();
            obj.TableName = TableName;
            obj.InUse     = InUse;
            return(obj);
        }
Exemplo n.º 4
0
        public object Clone()
        {
            FieldCollection fc = new FieldCollection();

            if (_fields != null)
            {
                fc._fields = _fields.Clone() as FieldList;
            }
            return(fc);
        }
        public void Store(Guid id, string language, FieldList data)
        {
            FieldList clonedData;

            try
            {
                clonedData = data.Clone();
            }
            catch (InvalidOperationException)
            {
                // Can happen sometimes, when we enumerate over the data, that the data was modified.
                // In that case, simply skip the caching.
                return;
            }

            lock (_lock)
            {
                if (!_cache.ContainsKey(id))
                {
                    _IdQueue.Enqueue(id);
                    _cache[id] = new ConcurrentDictionary <string, FieldList>();

                    // Only evict items, if there is no publishing or indexing in progress.
                    while (!_detectFullCategoryScan.FullCatalogScanInProgress && _IdQueue.Count > MaxCapacity)
                    {
                        Guid evictId;
                        if (_IdQueue.TryDequeue(out evictId))
                        {
                            EvictItem(evictId);
                        }
                    }
                }

                _cache[id][language] = clonedData;
            }
        }
Exemplo n.º 6
0
        private void FormFields_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            labDataSource.Text = DataName;

            FieldListClone = FieldList.Clone() as FieldsCollections;

            for (int i = 0; i < FieldList.Count; i++)
            {
                FieldItem temp = FieldListClone[i];
                LB_fldList.Items.Add(temp.DataTableName + "->" + temp.FieldChineseName + "." + temp.FieldName);
            }

            if (FieldList.Count > 0)
            {
                LB_fldList.SetSelected(0, true);
            }
            dtFields = _dao.GetFieldList();
            ShowFields(dtFields);
        }
        private void btQueryBuilder_Click(object sender, System.EventArgs e)
        {
            acceptByMouse();
            EasyQuery qry = objRet.SourceQuery;

            if (qry == null)
            {
                qry = new EasyQuery();
                qry.DatabaseConnection = dbConn;
                if (_tables == null)
                {
                    _tables = new TableAliasList();
                    for (int i = 0; i < lstTable.Items.Count; i++)
                    {
                        TableAlias t = new TableAlias((string)(lstTable.Items[i]), string.Empty);
                        _tables.AddTable(t);
                    }
                }
                qry.T = _tables;
                FieldList lst = objRet.GetFields();
                if (lst != null)
                {
                    FieldList fl = (FieldList)lst.Clone();
                    for (int i = 0; i < fl.Count; i++)
                    {
                        fl[i].FieldText = fl[i].Name;
                        if (lst[i].FromTableName != null)
                        {
                            if (lst[i].FromTableName.Length > 0)
                            {
                                if (!qry.T.IsTableIncluded(lst[i].FromTableName))
                                {
                                    TableAlias t = new TableAlias(lst[i].FromTableName, "");
                                    t.srcType = enumRecSource.Table;
                                    qry.T.AddTable(t);
                                }
                            }
                        }
                    }
                    qry.Fields = fl;
                }
                string sl = objRet.Filter;
                if (sl == null)
                {
                    sl = "";
                }
                if (sl.Length > 0)
                {
                    if (sl.StartsWith("FROM ", StringComparison.OrdinalIgnoreCase))
                    {
                        sl       = sl.Substring(5);
                        sl       = sl.Trim();
                        qry.From = sl;
                    }
                    else
                    {
                        qry.From = objRet.TableName;
                        if (sl.StartsWith("WHERE ", StringComparison.OrdinalIgnoreCase))
                        {
                            sl = sl.Substring(6);
                            sl = sl.Trim();
                        }
                        qry.Where = sl;
                    }
                }
                else
                {
                    qry.From = objRet.TableName;
                }
            }
            qry.DatabaseConnection = dbConn;
            QueryParser qp = new QueryParser();

            if (qp.BuildQuery(qry, this))
            {
                string filter = "";
                bool   bOK    = false;
                objRet.SourceQuery = qp.query;
                qry = qp.query;
                if (!qry.Fields.FromSingleTable() || objRet.CommandType == enmNonQueryType.Delete)
                {
                    filter = qry.From;
                    if (filter.Length > 0)
                    {
                        filter = string.Format(CultureInfo.InvariantCulture, "{0}{1}", QueryParser.SQL_From(), filter);
                    }
                }
                if (qry.Where.Length > 0)
                {
                    filter = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", filter, QueryParser.SQL_Where(), qry.Where);
                }
                if (objRet.CommandType == enmNonQueryType.Delete)
                {
                    if (qry.From.IndexOf(objRet.TableName, StringComparison.OrdinalIgnoreCase) < 0)
                    {
                        MessageBox.Show(this, string.Format(System.Globalization.CultureInfo.InvariantCulture, "Table [{0}] not found in [{1}]", objRet.TableName, qry.From), this.Text, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        objRet.MultiRow = true;
                        txtWhere.Text   = filter;
                        objRet.SetFilter(filter);
                        bOK = true;
                    }
                }
                else
                {
                    filter        = adjustFilter(filter);
                    txtWhere.Text = filter;
                    objRet.SetFilter(filter);
                    objRet.ResetSQL();
                    bOK = true;
                }
                if (bOK)
                {
                    showSQL();
                }
            }
        }
Exemplo n.º 8
0
 public virtual Differences VisitFieldList(FieldList list1, FieldList list2,
   out FieldList changes, out FieldList deletions, out FieldList insertions){
   changes = list1 == null ? null : list1.Clone();
   deletions = list1 == null ? null : list1.Clone();
   insertions = list1 == null ? new FieldList() : list1.Clone();
   //^ assert insertions != null;
   Differences differences = new Differences();
   //Compare definitions that have matching key attributes
   TrivialHashtable matchingPosFor = new TrivialHashtable();
   TrivialHashtable matchedNodes = new TrivialHashtable();
   for (int j = 0, n = list2 == null ? 0 : list2.Count; j < n; j++){
     //^ assert list2 != null;
     Field nd2 = list2[j];
     if (nd2 == null || nd2.Name == null) continue;
     matchingPosFor[nd2.Name.UniqueIdKey] = j;
     insertions.Add(null);
   }
   for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
     //^ assert list1 != null && changes != null && deletions != null;
     Field nd1 = list1[i];
     if (nd1 == null || nd1.Name == null) continue;
     object pos = matchingPosFor[nd1.Name.UniqueIdKey];
     if (!(pos is int)) continue;
     //^ assert pos != null;
     //^ assume list2 != null; //since there was entry int matchingPosFor
     int j = (int)pos;
     Field nd2 = list2[j];
     //^ assume nd2 != null;
     //nd1 and nd2 have the same key attributes and are therefore treated as the same entity
     matchedNodes[nd1.UniqueKey] = nd1;
     matchedNodes[nd2.UniqueKey] = nd2;
     //nd1 and nd2 may still be different, though, so find out how different
     Differences diff = this.VisitField(nd1, nd2);
     if (diff == null){Debug.Assert(false); continue;}
     if (diff.NumberOfDifferences != 0){
       changes[i] = diff.Changes as Field;
       deletions[i] = diff.Deletions as Field;
       insertions[i] = diff.Insertions as Field;
       insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation
       Debug.Assert(diff.Changes == changes[i] && diff.Deletions == deletions[i] && diff.Insertions == insertions[i]);
       differences.NumberOfDifferences += diff.NumberOfDifferences;
       differences.NumberOfSimilarities += diff.NumberOfSimilarities;
       continue;
     }
     changes[i] = null;
     deletions[i] = null;
     insertions[i] = null;
     insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation
   }
   //Find deletions
   for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
     //^ assert list1 != null && changes != null && deletions != null;
     Field nd1 = list1[i]; 
     if (nd1 == null) continue;
     if (matchedNodes[nd1.UniqueKey] != null) continue;
     changes[i] = null;
     deletions[i] = nd1;
     insertions[i] = null;
     differences.NumberOfDifferences += 1;
   }
   //Find insertions
   for (int j = 0, n = list1 == null ? 0 : list1.Count, m = list2 == null ? 0 : list2.Count; j < m; j++){
     //^ assert list2 != null;
     Field nd2 = list2[j]; 
     if (nd2 == null) continue;
     if (matchedNodes[nd2.UniqueKey] != null) continue;
     insertions[n+j] = nd2;  //Records nd2 as an insertion into list1, along with its position in list2
     differences.NumberOfDifferences += 1; //REVIEW: put the size of the tree here?
   }
   if (differences.NumberOfDifferences == 0){
     changes = null;
     deletions = null;
     insertions = null;
   }
   return differences;
 }
Exemplo n.º 9
0
 public override FieldList VisitFieldList(FieldList fields)
 {
     if (fields == null) return null;
     return base.VisitFieldList(fields.Clone());
 }
 public FieldList GetFieldList(VersionUri version)
 {
     return(_fieldList.Clone());
 }