Example #1
0
        internal override IO.Item Commit()
        {
            if (!this.Completed)
            {
                this.DBItem = this.BuildItem();

                if (((Model.Relationship) this.Item).Related != null)
                {
                    Action relatedaction = this.Transaction.Get(((Model.Relationship) this.Item).Related.ID);

                    if (relatedaction != null)
                    {
                        this.DBItem.SetProperty("related_id", relatedaction.Commit().ID);
                    }
                    else
                    {
                        this.DBItem.SetProperty("related_id", ((Model.Relationship) this.Item).Related.ID);
                    }
                }

                // Watch for Source Item Versioning
                ((Model.Relationship) this.Item).Source.Superceded += Source_Superceded;

                this.Completed = true;
            }

            return(this.DBItem);
        }
Example #2
0
 public Item(Store Store, IO.Item DBItem)
 {
     this.Cache = Store.Session.GetItemCache(Store.ItemType, DBItem.ID, DBItem.ConfigID, DBItem.Generation, DBItem.IsCurrent);
     this.Store = Store;
     this.Initalise();
     this.UpdateProperties(DBItem);
 }
Example #3
0
        internal void UpdateProperties(IO.Item DBItem)
        {
            // Set State and Action
            switch (this.Action)
            {
            case Model.Item.Actions.Create:
            case Model.Item.Actions.Read:
            case Model.Item.Actions.Update:

                this.State  = Model.Item.States.Stored;
                this.Action = Model.Item.Actions.Read;

                break;

            case Model.Item.Actions.Delete:

                this.State = Model.Item.States.Deleted;

                break;
            }

            if (DBItem != null)
            {
                // Set PermissionID
                this.PermissionID = DBItem.GetProperty("permission_id");

                // Set LockedByID
                this.LockedByID = DBItem.GetProperty("locked_by_id");
            }
        }
Example #4
0
        internal IO.Item DBQuery(String ID)
        {
            IO.Item query = new IO.Item(this.ItemType.Name, "get");
            query.ID = ID;

            // Set Select
            if (String.IsNullOrEmpty(this.Select))
            {
                // Use default selection
                this.Select = "keyed_name";
            }

            query.Select = SystemProperties + "," + this.Select;

            foreach (PropertyTypes.Item proptype in this.SelectPropertyCache.Keys)
            {
                if (!proptype.Name.Equals("source_id"))
                {
                    IO.Item propquery = this.SelectPropertyCache[proptype].DBQuery();
                    query.SetPropertyItem(proptype.Name, propquery);
                }
            }

            foreach (Query relquery in this.Relationships)
            {
                query.AddRelationship(relquery.DBQuery());
            }

            return(query);
        }
Example #5
0
        internal void UnLock()
        {
            switch (this.State)
            {
            case Model.Item.States.Stored:

                switch (this.Locked)
                {
                case Model.Item.Locks.User:

                    IO.Item lockitem = new IO.Item(this.ItemType.Name, "unlock");
                    lockitem.ID        = this.ID;
                    lockitem.DoGetItem = false;
                    IO.Request  request  = this.ItemType.Session.IO.Request(IO.Request.Operations.ApplyItem, lockitem);
                    IO.Response response = request.Execute();

                    if (!response.IsError)
                    {
                        this.Locked = Model.Item.Locks.None;
                        this.Action = Model.Item.Actions.Read;
                    }
                    else
                    {
                        if (response.ErrorMessage == "Aras.Server.Core.ItemIsNotLockedException")
                        {
                            this.Locked = Model.Item.Locks.None;
                            this.Action = Model.Item.Actions.Read;
                        }
                        else
                        {
                            throw new Exceptions.ServerException(response);
                        }
                    }

                    break;

                case Model.Item.Locks.None:

                    // Item not Locked
                    this.Action = Model.Item.Actions.Read;

                    break;

                case Model.Item.Locks.OtherUser:

                    throw new Exceptions.ServerException("Item locked by another User");
                }

                break;

            case Model.Item.States.Deleted:

                throw new Exceptions.ArgumentException("Item is Deleted");

            default:

                break;
            }
        }
Example #6
0
        protected IO.Item BuildItem()
        {
            // Create IO Item
            IO.Item dbitem = new IO.Item(this.Item.ItemType.Name, this.Name);
            dbitem.ID = this.Item.ID;

            // Add Classification

            if (this.Item.Class == null)
            {
                dbitem.SetProperty("classification", null);
            }
            else
            {
                dbitem.SetProperty("classification", this.Item.Class.Fullname);
            }

            // Add Properties
            foreach (Property prop in this.Item.Properties)
            {
                if ((!this.Transaction.Session.OptimiseAML || prop.Modified) && !prop.Type.ReadOnly && !prop.Type.Name.Equals("source_id"))
                {
                    if (prop is Properties.Item)
                    {
                        // Check that related Item is processed
                        Properties.Item itemprop = (Properties.Item)prop;

                        if (itemprop.Value != null)
                        {
                            Action itempropaction = this.Transaction.Get(((Model.Item)itemprop.Value).ID);

                            if (itempropaction != null)
                            {
                                itempropaction.Commit();
                            }
                        }
                    }

                    dbitem.SetProperty(prop.Type.Name, prop.DBValue);
                }
            }

            // Add Relations
            foreach (Actions.Relationship relationshipaction in this.RelationshipsCache.Values)
            {
                IO.Item dbrelationship = relationshipaction.Commit();
                dbitem.AddRelationship(dbrelationship);
            }

            return(dbitem);
        }
Example #7
0
        internal override IO.Item Commit()
        {
            if (!this.Completed)
            {
                IO.Item     dbitem   = this.BuildItem();
                IO.Response response = this.SendItem(dbitem);

                if (!response.IsError)
                {
                    if (response.Items.Count() == 1)
                    {
                        this.Result = response.Items.First();

                        if (this.Result.ConfigID.Equals(this.Item.ConfigID))
                        {
                            if (!this.Result.ID.Equals(this.Item.ID))
                            {
                                // New Version of Item
                                Model.Item newversion = this.Item.Store.Get(this.Result.ID);
                                Model.Item oldversion = this.Item;
                                this.Item = newversion;
                                this.UpdateItem(this.Result);
                                oldversion.OnSuperceded(newversion);
                            }
                            else
                            {
                                this.UpdateItem(this.Result);
                            }
                        }
                        else
                        {
                            // Result does not match Item
                            throw new Exceptions.ServerException("Server response does not match original Item");
                        }
                    }

                    this.Completed = true;
                }
                else
                {
                    this.Completed = true;

                    if (response.ErrorMessage != "Aras.Server.Core.ItemIsNotLockedException")
                    {
                        throw new Exceptions.ServerException(response);
                    }
                }
            }

            return(this.Result);
        }
Example #8
0
        internal IO.Item DBQuery()
        {
            if (this.Condition != null)
            {
                IO.Item query = new IO.Item(this.ItemType.Name, "get");

                // Set Select
                if (String.IsNullOrEmpty(this.Select))
                {
                    // Use default selection
                    this.Select = "keyed_name";
                }

                query.OrderBy = this.OrderBy;

                query.Select = SystemProperties + "," + this.Select;

                // Set Where from Condtion
                query.Where = this.Condition.Where(this.ItemType);

                // Set Paging
                if (this.Paging)
                {
                    query.PageSize = this.PageSize;
                    query.Page     = this.Page;
                }

                foreach (PropertyTypes.Item proptype in this.SelectPropertyCache.Keys)
                {
                    if (!proptype.Name.Equals("source_id") && !proptype.Name.Equals("related_id"))
                    {
                        IO.Item propquery = this.SelectPropertyCache[proptype].DBQuery();
                        query.SetPropertyItem(proptype.Name, propquery);
                    }
                }

                foreach (Query relquery in this.Relationships)
                {
                    query.AddRelationship(relquery.DBQuery());
                }

                return(query);
            }
            else
            {
                return(null);
            }
        }
Example #9
0
        public void Refresh()
        {
            // Run Query
            IO.Item dbquery = this.Query.DBQuery();

            if (dbquery != null)
            {
                if (this.Source != null)
                {
                    dbquery.SetProperty("source_id", this.Source.ID);
                }

                IO.Request  request  = this.ItemType.Session.IO.Request(IO.Request.Operations.ApplyItem, dbquery);
                IO.Response response = request.Execute();

                if (!response.IsError)
                {
                    this.Load(response.Items);

                    if (this.Paging)
                    {
                        if (response.Items.Count() > 0)
                        {
                            this.NoPages = response.Items.First().PageMax;
                        }
                        else
                        {
                            this.NoPages = 0;
                        }
                    }
                    else
                    {
                        this.NoPages = 0;
                    }
                }
                else
                {
                    if (!response.ErrorMessage.Equals("No items of type " + this.ItemType.Name + " found."))
                    {
                        throw new Exceptions.ServerException(response);
                    }
                    else
                    {
                        this.Load(null);
                    }
                }
            }
        }
Example #10
0
        internal override IO.Item Commit()
        {
            if (!this.Completed)
            {
                // Write File to Cache
                using (FileStream cachefile = new FileStream(((Model.File) this.Item).CacheFilename.FullName, FileMode.Open))
                {
                    IO.Response response = this.Transaction.Session.IO.VaultWrite(cachefile, ((Model.File) this.Item).VaultFilename);

                    if (!response.IsError)
                    {
                        if (response.Items.Count() == 1)
                        {
                            this.Result = response.Items.First();

                            if (this.Result.ConfigID.Equals(this.Item.ConfigID))
                            {
                                if (!this.Result.ID.Equals(this.Item.ID))
                                {
                                    // New Version of Item
                                    //Model.Item newversion = this.Item.Session.Store(this.Item.ItemType).Get(this.Result);
                                    //Model.Item oldversion = this.Item;
                                    //this.Item = newversion;
                                    //this.UpdateItem(this.Result);
                                    //oldversion.OnSuperceded(newversion);
                                }
                                else
                                {
                                    this.UpdateItem(this.Result);
                                }

                                this.Item.UpdateProperties(this.Result);
                            }
                            else
                            {
                                // Result does not match Item
                                throw new Exceptions.ServerException("Server response does not match original Item");
                            }
                        }
                    }
                }

                this.Completed = true;
            }

            return(this.Result);
        }
Example #11
0
        public void Process()
        {
            Aras.IO.Item files = new IO.Item("File", "get");
            files.Select = "id,filename";
            Aras.IO.Request request = IO.Request(Aras.IO.Request.Operations.ApplyItem);
            request.AddItem(files);
            Aras.IO.Response response = request.Execute();

            foreach (Aras.IO.Item file in response.Items)
            {
                String        id            = file.ID;
                DirectoryInfo firstleveldir = new DirectoryInfo(this.Vault.FullName + "\\" + id.Substring(0, 1));

                if (!firstleveldir.Exists)
                {
                    firstleveldir.Create();
                }

                DirectoryInfo secondleveldir = new DirectoryInfo(firstleveldir.FullName + "\\" + id.Substring(1, 2));

                if (!secondleveldir.Exists)
                {
                    secondleveldir.Create();
                }

                DirectoryInfo thirdleveldir = new DirectoryInfo(secondleveldir.FullName + "\\" + id.Substring(3, id.Length - 3));

                if (!thirdleveldir.Exists)
                {
                    thirdleveldir.Create();
                }

                FileInfo filename = new FileInfo(thirdleveldir.FullName + "\\" + file.GetProperty("filename"));

                if (!filename.Exists)
                {
                    using (StreamWriter sw = new StreamWriter(filename.FullName))
                    {
                        sw.WriteLine("Dummy File");
                    }
                }
            }
        }
Example #12
0
        public void Promote(Relationships.LifeCycleState NewState)
        {
            IO.Request request = this.ItemType.Session.IO.Request(IO.Request.Operations.PromoteItem);
            IO.Item    item    = request.NewItem(this.ItemType.Name, "get");
            item.ID = this.ID;
            item.SetProperty("state", NewState.Name);
            IO.Response response = request.Execute();

            if (!response.IsError)
            {
                // Update Current State
                this.Property(this.ItemType.PropertyType("current_state")).SetValue(NewState);
                this.Property(this.ItemType.PropertyType("state")).SetValue(NewState.Name);
            }
            else
            {
                throw new Exceptions.ServerException(response);
            }
        }
Example #13
0
        internal Model.Item Create(IO.Item DBItem)
        {
            Model.Item ret = null;

            if (this.Cache.ContainsKey(DBItem.ID))
            {
                ret = this.Cache[DBItem.ID];
                ret.UpdateProperties(DBItem);
            }
            else
            {
                // Create Item
                ret = (Model.Item) this.ItemType.Class.GetConstructor(new Type[] { typeof(Store), typeof(IO.Item) }).Invoke(new object[] { this, DBItem });

                // Add to Cache
                this.AddToCache(ret);
            }

            return(ret);
        }
Example #14
0
        public IEnumerable <Relationships.LifeCycleState> NextStates()
        {
            List <Relationships.LifeCycleState> ret = new List <Relationships.LifeCycleState>();

            if (this.State == Model.Item.States.Stored)
            {
                if (this.LifeCycleMap != null)
                {
                    IO.Request request = this.ItemType.Session.IO.Request(IO.Request.Operations.GetItemNextStates);
                    IO.Item    item    = request.NewItem(this.ItemType.Name, "get");
                    item.ID = this.ID;
                    IO.Response response = request.Execute();

                    if (!response.IsError)
                    {
                        if (response.Items.Count() > 0)
                        {
                            IO.Item lifecycletransisiton = response.Items.First();

                            foreach (IO.Item dblifecyclestate in lifecycletransisiton.ToStates)
                            {
                                foreach (Relationships.LifeCycleState lifecyclestate in this.LifeCycleMap.Relationships("Life Cycle State"))
                                {
                                    if (lifecyclestate.ID.Equals(dblifecyclestate.ID))
                                    {
                                        ret.Add(lifecyclestate);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exceptions.ServerException(response);
                    }
                }
            }

            return(ret);
        }
Example #15
0
        protected void UpdateItem(IO.Item DBItem)
        {
            // Update Properties
            this.Item.UpdateProperties(DBItem);

            foreach (Actions.Relationship relation in this.RelationshipsCache.Values)
            {
                Boolean found = false;

                foreach (IO.Item dbrelationship in DBItem.Relationships)
                {
                    if (dbrelationship.ID.Equals(relation.Item.ID))
                    {
                        relation.Item.UpdateProperties(dbrelationship);
                        found = true;
                    }
                }

                if (!found)
                {
                    relation.Item.UpdateProperties(null);
                }
            }
        }
Example #16
0
        public Response VaultWrite(Stream Stream, String Filename)
        {
            IO.Response response = null;

            // Read Cached File
            byte[] filebytes = null;

            if (Stream is MemoryStream)
            {
                filebytes = ((MemoryStream)Stream).ToArray();
            }
            else
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    Stream.CopyTo(ms);
                    filebytes = ms.ToArray();
                }
            }

            // Build Request
            String contentboundary           = "-------------S36Ut9A3ZtWwum";
            MultipartFormDataContent content = new MultipartFormDataContent(contentboundary);

            StringContent soapaction = new StringContent("ApplyItem");

            content.Add(soapaction, "SOAPACTION");

            StringContent authuser = new StringContent(this.Username);

            content.Add(authuser, "AUTHUSER");

            StringContent password = new StringContent(this.Password);

            content.Add(password, "AUTHPASSWORD");

            StringContent database = new StringContent(this.Database.ID);

            content.Add(database, "DATABASE");

            StringContent locale = new StringContent("");

            content.Add(locale, "LOCALE");

            StringContent timezone = new StringContent("GMT Standard Time");

            content.Add(timezone, "TIMEZONE_NAME");

            StringContent vault = new StringContent(this.VaultID);

            content.Add(vault, "VAULTID");

            IO.Item dbfile = new IO.Item("File", "add");
            dbfile.ID = Server.NewID();
            dbfile.SetProperty("filename", Filename);
            dbfile.SetProperty("file_size", filebytes.Length.ToString());
            IO.Item dbloacted = new IO.Item("Located", "add");
            dbloacted.SetProperty("related_id", this.VaultID);
            dbfile.AddRelationship(dbloacted);

            String        xmldata = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"><SOAP-ENV:Body><ApplyItem>" + dbfile.GetString() + "</ApplyItem></SOAP-ENV:Body></SOAP-ENV:Envelope>";
            StringContent xml     = new StringContent(xmldata);

            content.Add(xml, "XMLdata");

            ByteArrayContent filedata = new ByteArrayContent(filebytes);

            content.Add(filedata, dbfile.ID, Filename);

            // Post Request to Vault Server
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.VaultBaseURL);

            request.CookieContainer        = this.Cookies;
            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
            request.ContentType            = "multipart/form-data; boundary=" + contentboundary;
            request.Method      = "POST";
            request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
            request.Headers.Add("Cache-Control", "no-cache");
            request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";

            using (Stream poststream = request.GetRequestStream())
            {
                content.CopyToAsync(poststream);
            }

            using (HttpWebResponse webresponse = (HttpWebResponse)request.GetResponse())
            {
                using (Stream result = webresponse.GetResponseStream())
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(result);
                    response = new IO.Response(webresponse.Cookies, doc);
                }
            }

            return(response);
        }
Example #17
0
        private void Lock()
        {
            switch (this.State)
            {
            case Model.Item.States.Stored:

                switch (this.Locked)
                {
                case Model.Item.Locks.None:

                    // Lock Item
                    IO.Item lockitem = new IO.Item(this.ItemType.Name, "lock");
                    lockitem.ID        = this.ID;
                    lockitem.DoGetItem = false;
                    IO.Request  request  = this.ItemType.Session.IO.Request(IO.Request.Operations.ApplyItem, lockitem);
                    IO.Response response = request.Execute();

                    if (!response.IsError)
                    {
                        this.Locked = Model.Item.Locks.User;
                        this.Action = Model.Item.Actions.Update;
                    }
                    else
                    {
                        if ((response.ErrorMessage != null) && response.ErrorMessage.Equals("Aras.Server.Core.ItemIsAlreadyLockedException"))
                        {
                            // Already Locked
                            this.Locked = Model.Item.Locks.User;
                            this.Action = Model.Item.Actions.Update;
                        }
                        else
                        {
                            throw new Exceptions.ServerException(response);
                        }
                    }

                    break;

                case Model.Item.Locks.User:

                    // Already locked by User
                    this.Action = Model.Item.Actions.Update;

                    break;

                case Model.Item.Locks.OtherUser:

                    throw new Exceptions.ServerException("Item locked by another user");
                }

                break;

            case Model.Item.States.Deleted:

                throw new Exceptions.ArgumentException("Item is Deleted");

            case Model.Item.States.New:

                // New Item not stored in database, no need to lock

                break;
            }
        }
Example #18
0
 public Located(Store Store, IO.Item DBItem)
     : base(Store, DBItem)
 {
 }
Example #19
0
 public List(Store Store, IO.Item DBItem)
     : base(Store, DBItem)
 {
 }
Example #20
0
 public User(Store Store, IO.Item DBItem)
     : base(Store, DBItem)
 {
 }
Example #21
0
 public PartCAD(Model.Store Store, IO.Item DBItem)
     : base(Store, DBItem)
 {
 }
Example #22
0
 public Permission(Store Store, IO.Item DBItem)
     : base(Store, DBItem)
 {
 }
Example #23
0
 internal Item(Transaction Transaction, String Name, Model.Item Item)
     : base(Transaction, Name, Item)
 {
     this.Result = null;
 }
Example #24
0
 public Relationship(Store Store, IO.Item DBItem)
     : base(Store, DBItem)
 {
 }
Example #25
0
 internal Relationship(Transaction Transaction, String Name, Model.Relationship Relationship)
     : base(Transaction, Name, Relationship)
 {
     this.DBItem = null;
 }
Example #26
0
        private void BuildCaches()
        {
            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);
            }
        }
Example #27
0
        internal void UpdateProperties(IO.Item DBItem)
        {
            this.Cache.UpdateProperties(DBItem);

            if (DBItem != null)
            {
                // Update Classification
                this.Class = this.ItemType.GetClassFullname(DBItem.GetProperty("classification"));

                if (this.ID.Equals(DBItem.ID))
                {
                    // Update Properties
                    foreach (Property property in this.PropertyCache.Values)
                    {
                        if (property is Properties.Item)
                        {
                            if (property.Type.Name.Equals("source_id"))
                            {
                                ((Properties.Item)property).SetDBValue(this.Store.Source);
                            }
                            else
                            {
                                IO.Item dbpropitem = DBItem.GetPropertyItem(property.Type.Name);

                                if (dbpropitem != null)
                                {
                                    property.DBValue = this.Store.Query.Property((PropertyTypes.Item)property.Type).Store.Create(dbpropitem).ID;
                                }
                                else
                                {
                                    // Check if just ID Specified
                                    String itemid = DBItem.GetProperty(property.Type.Name);

                                    if (!String.IsNullOrEmpty(itemid))
                                    {
                                        property.DBValue = itemid;
                                    }
                                    else
                                    {
                                        property.DBValue = null;
                                    }
                                }
                            }
                        }
                        else
                        {
                            property.DBValue = DBItem.GetProperty(property.Type.Name);
                        }
                    }

                    Dictionary <RelationshipType, List <IO.Item> > dbrels = new Dictionary <RelationshipType, List <IO.Item> >();

                    foreach (IO.Item dbrel in DBItem.Relationships)
                    {
                        ItemType reltype = this.Store.Session.ItemType(dbrel.ItemType);

                        if (reltype is RelationshipType)
                        {
                            if (!dbrels.ContainsKey((RelationshipType)reltype))
                            {
                                dbrels[(RelationshipType)reltype] = new List <IO.Item>();
                            }

                            dbrels[(RelationshipType)reltype].Add(dbrel);
                        }
                    }

                    foreach (RelationshipType reltype in dbrels.Keys)
                    {
                        this.RelationshipsCache[reltype].Load(dbrels[reltype]);
                    }
                }
                else
                {
                    throw new Exceptions.ArgumentException("Invalid Item ID: " + DBItem.ID);
                }
            }
        }
Example #28
0
 public CADStructure(Model.Store Store, IO.Item DBItem)
     : base(Store, DBItem)
 {
 }
Example #29
0
 public Vault(Store Store, IO.Item DBItem)
     : base(Store, DBItem)
 {
 }
Example #30
0
 protected IO.Response SendItem(IO.Item DBItem)
 {
     // Send to Server
     IO.Request request = this.Transaction.Session.IO.Request(IO.Request.Operations.ApplyItem, DBItem);
     return(request.Execute());
 }