示例#1
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="Propertystr"></param>
        /// <returns></returns>
        public JsonResult GetUserProperty(string UserID, string Propertystr)
        {
            return(ExecuteFunctionRun(() =>
            {
                if (string.IsNullOrWhiteSpace(UserID))
                {
                    return null;
                }
                string[] Propertys = Propertystr.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                if (Propertys == null)
                {
                    return null;
                }

                Dictionary <string, object> PropertyJson = new Dictionary <string, object>();


                Organization.Unit unit = this.Engine.Organization.GetUnit(UserID);
                if (unit == null)
                {
                    unit = this.Engine.Organization.GetUserByCode(UserID);
                    if (unit == null)
                    {
                        return null;
                    }
                }

                foreach (string p in Propertys)
                {
                    if (PropertyJson.ContainsKey(p))
                    {
                        continue;
                    }
                    switch (p)
                    {
                    case Organization.User.PropertyName_DepartmentName:
                        if (unit.UnitType == Organization.UnitType.User)
                        {
                            PropertyJson.Add(p, ((OThinker.Organization.User)unit).DepartmentName);
                        }
                        break;

                    default:
                        PropertyInfo PropertyInfo = unit.GetType().GetProperty(p);
                        if (PropertyInfo == null)
                        {
                            PropertyJson.Add(p, null);
                        }
                        else
                        {
                            PropertyJson.Add(p, PropertyInfo.GetValue(unit, null));
                        }
                        break;
                    }
                }

                return Json(PropertyJson, JsonRequestBehavior.AllowGet);
            }, string.Empty));
        }