예제 #1
0
        private void GetProjectOrderNumberTree(HttpContext context)
        {
            int CompanyID = 0;

            int.TryParse(context.Request.Params["CompanyID"], out CompanyID);
            int ID = 0;

            int.TryParse(context.Request.Params["ID"], out ID);
            string Keywords      = context.Request.Params["Keywords"];
            int    OrderNumberID = 0;

            int.TryParse(context.Request.Params["OrderNumberID"], out OrderNumberID);
            int Level = 0;

            int.TryParse(context.Request.Params["Level"], out Level);
            if (Level <= 0)
            {
                Level = 2;
            }
            int UserID = WebUtil.GetUser(context).UserID;

            ProjectTree[] list = ProjectTree.GetProjectTreeListByOrderNumberID(ID, Keywords, OrderNumberID, Level, UserID).ToArray();
            List <Dictionary <string, object> > items = null;

            if (string.IsNullOrEmpty(Keywords))
            {
                items = list.Select(p =>
                {
                    var dic = p.ToJsonObject();
                    if (p.ID == 1)
                    {
                        var company = Company.GetCompany(CompanyID);
                        dic["name"] = company.CompanyName;
                    }
                    else
                    {
                        dic["name"] = p.Name;
                    }
                    dic["id"]       = p.ID;
                    dic["pId"]      = p.ParentID;
                    dic["iconSkin"] = "Icon_" + p.IconID;
                    dic["open"]     = true;
                    dic["checked"]  = OrderNumberID != 0 && p.OrderNumberID == OrderNumberID;
                    if (p.IconID == Level)
                    {
                        dic["isParent"] = false;
                    }
                    return(dic);
                }).ToList();
            }
            else
            {
                items = list.Select(p =>
                {
                    var dic = p.ToJsonObject();
                    if (p.ID == 1)
                    {
                        var company = Company.GetCompany(CompanyID);
                        dic["name"] = company.CompanyName;
                    }
                    else
                    {
                        dic["name"] = p.FullName + p.Name;
                    }
                    dic["id"]       = p.ID;
                    dic["pId"]      = p.ParentID;
                    dic["iconSkin"] = "Icon_" + p.IconID;
                    dic["open"]     = true;
                    dic["checked"]  = OrderNumberID != 0 && p.OrderNumberID == OrderNumberID;
                    if (p.IconID == Level)
                    {
                        dic["isParent"] = false;
                    }
                    return(dic);
                }).ToList();
            }
            string result = JsonConvert.SerializeObject(items);

            context.Response.Write(result);
        }