예제 #1
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);
        }
예제 #2
0
파일: Action.cs 프로젝트: y1026/Aras.Model
        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);
        }
예제 #3
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);
            }
        }
예제 #4
0
파일: Session.cs 프로젝트: y1026/Aras.Model
        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);
            }
        }
예제 #5
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);
        }