Beispiel #1
0
        //[HttpPost]
        public ActionResult GetClass()
        {
            string parentCode = DoRequest.Request("parentCode");
            string code       = DoRequest.Request("Code");

            List <PicTypeList> sysFClassList = new List <PicTypeList>();
            var restype = GetSysFileType.Do(-1);

            if (restype != null && restype.Body != null && restype.Body.type_list != null)
            {
                sysFClassList = restype.Body.type_list;
            }

            PicTypeList pInfo = sysFClassList.FindLast(delegate(PicTypeList item) { return(item.type_code.Equals(parentCode)); });
            PicTypeList tInfo = sysFClassList.FindLast(delegate(PicTypeList item) { return(item.type_code.Equals(code)); });

            if (pInfo == null)
            {
                pInfo = new PicTypeList();
            }
            if (tInfo == null)
            {
                tInfo = new PicTypeList();
            }
            if (tInfo.sp_type_id < 1)
            {
                List <PicTypeList> temList = sysFClassList.FindAll(delegate(PicTypeList item) { return(item.parent_code == parentCode); });
                tInfo.sort_no = 1;
                foreach (PicTypeList node in temList)
                {
                    if (tInfo.sort_no <= node.sort_no)
                    {
                        tInfo.sort_no += 1;
                    }
                }
            }

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            string[] arr = pInfo.type_path.Split(',');
            sb.Append("根");
            foreach (string s in arr)
            {
                if (string.IsNullOrEmpty(s))
                {
                    continue;
                }
                //int val = Utils.StrToInt(s.Trim());
                List <PicTypeList> list = sysFClassList.FindAll(
                    delegate(PicTypeList item)
                {
                    return(item.type_code.Equals(s));
                });
                if (list.Count > 0)
                {
                    sb.Append(" >> " + list[0].sp_type_name);
                }
            }
            return(Json(new { parent = pInfo, type = tInfo, parentName = sb.ToString() }, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public ActionResult PostSysFileCategData()
        {
            string parentCode = DoRequest.GetFormString("parentCode");
            string code       = DoRequest.GetFormString("code");
            int    typeId     = DoRequest.GetFormInt("typeId");
            string name       = DoRequest.GetFormString("name").Trim();
            int    sort       = DoRequest.GetFormInt("sort");
            int    issys      = DoRequest.GetFormInt("isSys");

            #region 验证
            if (string.IsNullOrEmpty(name))
            {
                return(Json(new { error = true, message = "名称不能为空" }));
            }
            if (string.IsNullOrEmpty(code))
            {
                return(Json(new { error = true, message = "编码不能为空" }));
            }
            if (Utils.IsLong(code))
            {
                return(Json(new { error = true, message = "编码不能是纯数字" }));
            }
            if (!Utils.IsMatch(code, @"^[0-9a-zA-Z\-]{1,100}$"))
            {
                return(Json(new { error = true, message = "编码只能是数字、字母或中划线(-)" }));
            }
            #endregion
            List <PicTypeList> sysFClassList = new List <PicTypeList>();
            var restype = GetSysFileType.Do(-1);
            if (restype != null && restype.Body != null && restype.Body.type_list != null)
            {
                sysFClassList = restype.Body.type_list;
            }

            PicTypeList pNode = sysFClassList.FindLast(delegate(PicTypeList item) { return(item.type_code.Equals(parentCode)); });
            PicTypeList cNode = sysFClassList.FindLast(delegate(PicTypeList item) { return(item.sp_type_id == typeId); });
            if (pNode == null)
            {
                pNode = new PicTypeList();
            }
            if (cNode == null)
            {
                cNode = new PicTypeList();
            }
            #region 初始化参数
            cNode.parent_code  = pNode.type_code;
            cNode.type_code    = code;
            cNode.sp_type_name = name;
            cNode.sort_no      = sort;
            cNode.is_sys       = issys;
            #endregion

            int returnValue = -1;
            if (cNode.sp_type_id < 1)
            {
                //新增
                cNode.sp_type_state = 0;
            }

            var res = OpSysFileType.Do(cNode);
            if (res != null && res.Header != null && res.Header.Result != null && res.Header.Result.Code != null)
            {
                returnValue = Utils.StrToInt(res.Header.Result.Code, -1);
            }
            if (returnValue == 0)
            {
                return(Json(new { error = false, message = "操作成功!" }));
            }
            return(Json(new { error = true, message = "操作失败!" }));
        }