Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest rp = context.Request;
            string msg = string.Empty;
            try
            {

                if (string.IsNullOrEmpty(rp["txtID"]))
                {
                    entity.ID = Guid.NewGuid();
                }
                else
                {
                    entity.ID = new Guid(rp["txtID"]);
                    entity.RecordStatus = StatusType.update;
                }

                entity.Code = rp["txtCode"];
                entity.Name = rp["txtName"];
                entity.RoleClass = rp["txtRoleClass"];
                entity.IsEnable = rp["txtIsEnable"] == "on";
                entity.Note = rp["txtNote"];
                RoleInfoManager manager = new RoleInfoManager();
                bool IsExit = manager.ExitCodeAndName(entity);//重复校验参考
                if (IsExit)
                {
                    msg = "已存在相同编号或名称!";
                }
                else
                {
                    manager.Save(entity);
                    context.Response.Write("{\"success\":\"true\",\"ID\":\"" + entity.ID + "\"}");
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            if (!string.IsNullOrEmpty(msg))
            {
                byte[] bytes = Encoding.UTF8.GetBytes(msg.Replace("\r\n", "<br/>"));
                string encode = Convert.ToBase64String(bytes);
                context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}");
            }
            context.Response.End();
        }
Exemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest rp = context.Request;
            string msg = string.Empty;
            try
            {
                Guid RoleID = new Guid(rp["roleID"]);
                string personID = rp["person"];
                string[] personArray = personID.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                List<BaseEntity> list = new List<BaseEntity>();
                foreach (string item in personArray)
                {
                    RolePerson rpi = new RolePerson();
                    rpi.ID = Guid.NewGuid();
                    rpi.PersonID = new Guid(item);
                    rpi.RoleID = RoleID;
                    list.Add(rpi);

                }
                RoleInfoManager manager = new RoleInfoManager();
                manager.Save(list);
                context.Response.Write("{\"success\":\"true\"}");

            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            if (!string.IsNullOrEmpty(msg))
            {
                byte[] bytes = Encoding.UTF8.GetBytes(msg.Replace("\r\n", "<br/>"));
                string encode = Convert.ToBase64String(bytes);
                context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}");
            }
            context.Response.End();
        }