Exemplo n.º 1
0
        public virtual void SaveResource(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    mode    = request.GetString("mode");

            JsonSerializer serializer = new JsonSerializer();
            StreamReader   reader     = new StreamReader(context.Request.InputStream);

            using (JsonTextReader streamReader = new JsonTextReader(reader))
            {
                JArray @params = serializer.Deserialize(streamReader) as JArray;

                UserResource resource = @params[0].ToObject <UserResource>(serializer);
                UserResourcePermisionCollection perms = @params[1].ToObject <UserResourcePermisionCollection>(serializer);

                using (BPMConnection cn = new BPMConnection())
                {
                    cn.WebOpen();

                    if (mode == "edit")
                    {
                        string rsid = request.GetString("rsid");
                        UserResource.Save(cn, rsid, resource, perms);
                    }
                    else
                    {
                        string parentRsid = request.GetString("parentRsid", null);
                        UserResource.SaveAs(cn, parentRsid, resource, perms);
                    }
                }
            }
        }