Beispiel #1
0
 public Query Query(ItemType ItemType)
 {
     return(new Query(ItemType));
 }
Beispiel #2
0
        private void BuildCaches()
        {
            lock (this.ItemTypeCacheLock)
            {
                this.ItemTypeNameCache = new Dictionary <String, ItemType>();
                this.ItemTypeIDCache   = new Dictionary <String, ItemType>();

                // Build ItemType Cache
                IO.Request itemtyperequest = this.IO.Request(Aras.IO.Request.Operations.ApplyItem);
                IO.Item    itemtypequery   = itemtyperequest.NewItem("ItemType", "get");
                itemtypequery.Select = "id,name,is_relationship,class_structure,label,label_plural";

                IO.Item lifecyclemapquery = itemtyperequest.NewItem("ItemType Life Cycle", "get");
                lifecyclemapquery.Select = "class_path,related_id";
                itemtypequery.AddRelationship(lifecyclemapquery);

                IO.Response itemtyperesponse = itemtyperequest.Execute();

                if (!itemtyperesponse.IsError)
                {
                    foreach (IO.Item dbitem in itemtyperesponse.Items)
                    {
                        ItemType itemtype = null;

                        if (dbitem.GetProperty("is_relationship").Equals("1"))
                        {
                            itemtype = new RelationshipType(this, dbitem.ID, dbitem.GetProperty("name"), dbitem.GetProperty("label"), dbitem.GetProperty("label_plural"), dbitem.GetProperty("class_structure"));
                        }
                        else
                        {
                            itemtype = new ItemType(this, dbitem.ID, dbitem.GetProperty("name"), dbitem.GetProperty("label"), dbitem.GetProperty("label_plural"), dbitem.GetProperty("class_structure"));
                        }

                        this.ItemTypeIDCache[itemtype.ID]     = itemtype;
                        this.ItemTypeNameCache[itemtype.Name] = itemtype;

                        foreach (IO.Item itemtypelifecyclemap in dbitem.Relationships)
                        {
                            itemtype.AddLifeCycleMap(itemtypelifecyclemap.GetProperty("class_path"), itemtypelifecyclemap.GetPropertyItem("related_id").ID);
                        }
                    }
                }
                else
                {
                    throw new Exceptions.ServerException(itemtyperesponse);
                }

                // Build RelationshipType Cache
                IO.Request relationshiptyperequest = this.IO.Request(Aras.IO.Request.Operations.ApplyItem);
                IO.Item    relationshiptypequery   = relationshiptyperequest.NewItem("RelationshipType", "get");
                relationshiptypequery.Select = "relationship_id,source_id(id),related_id(id),grid_view";
                IO.Response relationshiptyperesponse = relationshiptyperequest.Execute();

                if (!relationshiptyperesponse.IsError)
                {
                    foreach (IO.Item dbitem in relationshiptyperesponse.Items)
                    {
                        RelationshipType relationshiptype = (RelationshipType)this.ItemTypeIDCache[dbitem.GetProperty("relationship_id")];

                        String source_id = dbitem.GetProperty("source_id");

                        if (!String.IsNullOrEmpty(source_id))
                        {
                            relationshiptype.Source = this.ItemTypeIDCache[source_id];
                            relationshiptype.Source.AddRelationshipType(relationshiptype);
                        }

                        String related_id = dbitem.GetProperty("related_id");

                        if (!String.IsNullOrEmpty(related_id))
                        {
                            relationshiptype.Related = this.ItemTypeIDCache[related_id];
                        }

                        switch (dbitem.GetProperty("grid_view"))
                        {
                        case "right":
                            relationshiptype.RelationshipGridView = RelationshipGridViews.Right;
                            break;

                        case "intermix":
                            relationshiptype.RelationshipGridView = RelationshipGridViews.InterMix;
                            break;

                        default:
                            relationshiptype.RelationshipGridView = RelationshipGridViews.Left;
                            break;
                        }
                    }
                }
                else
                {
                    throw new Exceptions.ServerException(relationshiptyperesponse);
                }
            }
        }