Beispiel #1
0
        }                                                          //系统管理_用户类别管理_编辑页面
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string userType = this.UserType;
                if (string.IsNullOrWhiteSpace(userType))
                {
                    return;
                }

                txtUserType.Text    = userType;
                txtUserType.Enabled = false;
                txtDescription.Text = userTypeManage.GetDescription(userType);
            }
        }
Beispiel #2
0
        internal static string UserJson(User user) //Change to internal when done
        {
            string Json = "{\n" +
                          "\"data\": {\n" +
                          "\"type\": \"registration_sets\",\n";

            // add "id" for updates
            if (!string.IsNullOrEmpty(user.UserId))
            {
                Json += "\"id\": \"" + user.UserId + "\",\n";
            }

            Json +=
                "\"attributes\": {\n" +
                "\"registrations\": [\n" +
                "{\n" +
                "\"rule_set\": \"user_rule_set\",\n" +
                "\"first_name\": \"" + user.FirstName + "\",\n" +
                "\"last_name\": \"" + user.LastName + "\",\n" +
                "\"email\": \"" + user.Email + "\"";
            if (user.SingleSignOnId != null)
            {
                Json += ",\n\"sso_id\": \"" + user.SingleSignOnId + "\"";
            }
            if (user.EmployeeId != null)
            {
                Json += ",\n\"employee_id\": \"" + user.EmployeeId + "\"";
            }
            if (user.StudentId != null)
            {
                Json += ",\n\"student_id\": \"" + user.StudentId + "\"";
            }

            if (user.Location != null)
            {
                Json += ",\n\"location_id\": \"" + user.Location.Id + "\"" +
                        "\n}";
            }
            else if (user.LocationId != null)
            {
                Json += ",\n\"location_id\": \"" + user.LocationId + "\"" +
                        "\n}";
            }
            else
            {
                Json += "\n}";
            }

            for (var i = 0; i < user.UserTypes.Count; i++)
            {
                Json += ",\n{\n" +
                        "\"rule_set\": \"" + UserType.GetDescription(user.UserTypes.ElementAt(i).Type) + "\",\n" +
                        "\"role\": \"" + UserType.GetDescription(user.UserTypes.ElementAt(i).Role) + "\"";
                if (i == 0)
                {
                    if (user.Position != null)
                    {
                        Json += ",\n\"position\": \"" + user.Position + "\"";
                    }
                    if (!user.FirstDay.Equals(DateTime.MinValue))
                    {
                        Json += ",\n\"first_day_of_work\": \"" + user.FirstDay + "\"";
                    }
                    if (!user.LastDay.Equals(DateTime.MinValue))
                    {
                        Json += ",\n\"last_day_of_work\": \"" + user.LastDay + "\"";
                    }
                }

                Json += "\n}";
            }

            Json += "\n";

            Json += "]\n}\n}\n}";

            return(Json);
        }