Ejemplo n.º 1
0
        public virtual object RelationshipAppGetUsedBy(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    fileid  = request.GetString("fileid");
            BPMObjectNameCollection spriteids   = JArray.Parse(request.GetString("spriteids")).ToObject <BPMObjectNameCollection>();
            BPMObjectNameCollection tagfiletype = JArray.Parse(request.GetString("tagfiletype")).ToObject <BPMObjectNameCollection>();
            JArray rv = new JArray();

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    File file = File.Load(provider, cn, fileid);
                    SpriteLinkCollection links = BPAManager.GetFileUsedByLinks(provider, cn, fileid, null);

                    foreach (SpriteLink link in links)
                    {
                        if (!String.IsNullOrEmpty(link.LinkedSpriteID) && spriteids.Count != 0 && !spriteids.Contains(link.LinkedSpriteID))
                        {
                            continue;
                        }

                        File usedbyFile = File.TryLoad(provider, cn, link.FileID);
                        if (usedbyFile == null)
                        {
                            continue;
                        }

                        AttachmentInfo usedByAttachment = AttachmentManager.GetAttachmentInfo(provider, cn, usedbyFile.FileID);
                        if (tagfiletype.Count != 0 && !tagfiletype.Contains(usedByAttachment.Ext))
                        {
                            continue;
                        }

                        Sprite usedbySprite = usedbyFile.Sprites.TryGetItem(link.SpriteID);
                        Sprite sprite       = file.Sprites.TryGetItem(link.LinkedSpriteID);

                        JObject item = new JObject();
                        rv.Add(item);
                        item["FileID"]             = file.FileID;
                        item["FileName"]           = file.FileName;
                        item["SpriteName"]         = SpriteIdentity.ConvertSpriteName(sprite == null ? "" : sprite.Name);
                        item["RelatiedFileID"]     = usedbyFile.FileID;
                        item["RelatiedFileName"]   = usedbyFile.FileName;
                        item["RelatiedSpriteName"] = SpriteIdentity.ConvertSpriteName(usedbySprite == null ? "" : usedbySprite.Name);
                    }

                    return(rv);
                }
            }
        }
Ejemplo n.º 2
0
        public virtual SpriteLinkCollection GetFileUsedByLinks(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    fileid  = request.GetString("fileid");

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    SpriteLinkCollection links = BPAManager.GetFileUsedByLinks(provider, cn, fileid, null);
                    foreach (SpriteLink link in links)
                    {
                        AttachmentInfo attachmentInfo = AttachmentManager.TryGetAttachmentInfo(provider, cn, link.FileID);
                        if (attachmentInfo != null)
                        {
                            link["FileName"]   = attachmentInfo.Name;
                            link["FileExt"]    = attachmentInfo.Ext;
                            link["Attachment"] = JObject.FromObject(attachmentInfo);
                        }

                        SpriteIdentity spriteIdentity = BPAManager.TryGetSpriteIdentity(provider, cn, link.FileID, link.SpriteID);
                        if (spriteIdentity != null)
                        {
                            link["SpriteName"] = spriteIdentity.Name;
                        }

                        //ExtJS grid grouping bug fix
                        if (String.IsNullOrEmpty(link.LinkedSpriteID))
                        {
                            link.LinkedSpriteID      = "process";
                            link["LinkedSpriteName"] = "流程";
                        }
                    }

                    return(links);
                }
            }
        }
Ejemplo n.º 3
0
        public virtual object RelationshipAppGetNonUsedBy(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    fileid  = request.GetString("fileid");
            BPMObjectNameCollection  spriteids   = JArray.Parse(request.GetString("spriteids")).ToObject <BPMObjectNameCollection>();
            BPMObjectNameCollection  tagfiletype = JArray.Parse(request.GetString("tagfiletype")).ToObject <BPMObjectNameCollection>();
            SpriteIdentityCollection rv          = new SpriteIdentityCollection();

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    File file = File.Load(provider, cn, fileid);
                    SpriteLinkCollection links = BPAManager.GetFileUsedByLinks(provider, cn, fileid, null);

                    foreach (Sprite sprite in file.Sprites.SortByOrder())
                    {
                        if (spriteids.Count != 0 && !spriteids.Contains(sprite.Id))
                        {
                            continue;
                        }

                        if (tagfiletype.Count == 0)
                        {
                            bool find = false;
                            foreach (SpriteLink link in links)
                            {
                                if (NameCompare.EquName(link.LinkedSpriteID, sprite.Id))
                                {
                                    find = true;
                                    break;
                                }
                            }

                            if (find)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            bool find = false;
                            foreach (SpriteLink link in links)
                            {
                                bool attachmentInfoSetted = link["attachmentInfoSetted"] == null ? false:Convert.ToBoolean(link["attachmentInfoSetted"]);

                                AttachmentInfo srcAttachment;
                                if (attachmentInfoSetted)
                                {
                                    srcAttachment = link["attachmentInfo"] as AttachmentInfo;
                                }
                                else
                                {
                                    srcAttachment                = AttachmentManager.TryGetAttachmentInfo(provider, cn, link.FileID);
                                    link["attachmentInfo"]       = srcAttachment;
                                    link["attachmentInfoSetted"] = true;
                                }

                                if (tagfiletype != null && tagfiletype.Contains(srcAttachment.Ext))
                                {
                                    find = true;
                                    break;
                                }
                            }

                            if (find)
                            {
                                continue;
                            }
                        }

                        rv.Add(new SpriteIdentity(sprite));
                    }

                    return(rv);
                }
            }
        }