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

            int.TryParse(context.Request.Params["CompanyID"], out CompanyID);
            string     ProjectIDs    = context.Request["ProjectIDs"];
            int        UserID        = WebUtil.GetUser(context).UserID;
            int        ContactID     = WebUtil.GetIntValue(context, "ContactID");
            List <int> ProjectIDList = new List <int>();

            if (!string.IsNullOrEmpty(ProjectIDs))
            {
                ProjectIDList = JsonConvert.DeserializeObject <List <int> >(ProjectIDs);
            }
            var list = ProjectTree.GetProjectTreeListByContactID(CompanyID, ContactID, UserID).ToArray();
            List <Dictionary <string, object> > items = null;

            items = list.Select(p =>
            {
                bool ischecked = ContactID != 0 && p.MsgID == ContactID;
                if (ProjectIDList.Count > 0 && ProjectIDList.Contains(p.ID))
                {
                    ischecked = true;
                }
                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"]  = ischecked;
                return(dic);
            }).ToList();
            string result = JsonConvert.SerializeObject(items);

            context.Response.Write(result);
        }