private static string GetUserRoleByValue(string roleNo)
        {
            string _role = string.Empty;

            if (String.IsNullOrWhiteSpace(roleNo))
            {
                _role = "No Role Assigned";
            }
            else
            {
                UiEnum.ShipRolesUmbraco valueEnum = (UiEnum.ShipRolesUmbraco)Enum.Parse(typeof(UiEnum.ShipRolesUmbraco), roleNo, true);
                _role = valueEnum.Description();
            }

            return(_role);
        }
        private static string GetUserRole(Umbraco.Core.Models.IMember auser)
        {
            string _role  = string.Empty;
            string roleNo = auser.GetValue("roleAssigned").ToString();

            if (String.IsNullOrWhiteSpace(roleNo))
            {
                _role = "No Role Assigned";
            }
            else
            {
                UiEnum.ShipRolesUmbraco valueEnum = (UiEnum.ShipRolesUmbraco)Enum.Parse(typeof(UiEnum.ShipRolesUmbraco), roleNo, true);
                _role = valueEnum.Description();
            }

            return(_role);
        }
Пример #3
0
        private static StringBuilder CreateCSVString(IEnumerable <Umbraco.Core.Models.IMember> userList)
        {
            var sb = new StringBuilder();

            sb.Append("Firstname\t Lastname\t Email\t State\t Role Applied For\t Role Assigned\t Add To Distribution List\t User Status\t Phone\t City\t Organization\t Reason\t  Last Logged in\t Registered date\t Number of logins\t Date approved\t Date denied\t Date inactive\t Last edited\n");


            foreach (var auser in userList)
            {
                string roleNo = auser.GetValue("roleAppliedFor").ToString();


                UiEnum.ShipRolesUmbraco valueEnum = (UiEnum.ShipRolesUmbraco)Enum.Parse(typeof(UiEnum.ShipRolesUmbraco), roleNo, true);


                string roleApplied = valueEnum.Description();


                // string roleAssignedNo = (auser.GetValue("roleAssigned") ?? "0").ToString();


                string roleAssigned = string.Empty;
                var    roles        = System.Web.Security.Roles.GetRolesForUser(auser.Email);
                roleAssigned = string.Join("^", roles);

                //if (String.IsNullOrWhiteSpace(roleAssignedNo))
                //{
                //    roleAssigned = "";
                //}
                //else
                //{
                //    UiEnum.ShipRolesUmbraco valueEnum1 = (UiEnum.ShipRolesUmbraco)Enum.Parse(typeof(UiEnum.ShipRolesUmbraco), roleAssignedNo, true);
                //    roleAssigned = valueEnum1.Description();

                //}

                string _reason = string.Empty;
                if (auser.GetValue("reason") != null)
                {
                    _reason = auser.GetValue("reason").ToString();
                }


                // (myObjc ?? "").ToString()

                string reason = System.Text.RegularExpressions.Regex.Replace(_reason, @"\t|\n|\r", " ");

                sb.Append(string.Format("{0}\t {1}\t {2}\t {3}\t {4}\t {5}\t {6}\t {7}\t {8}\t {9}\t {10}\t {11}\t {12}\t {13}\t {14}\t {15}\t {16}\t{17}\t{18}\n",
                                        (auser.GetValue("firstName") ?? "").ToString(),
                                        (auser.GetValue("lastName") ?? "").ToString(),
                                        auser.Email,
                                        (auser.GetValue("state") ?? "").ToString(),
                                        roleApplied,
                                        roleAssigned,

                                        (auser.GetValue("addToDistributionList") ?? "").ToString() == "1",
                                        Utils.GetUserStatus(auser),

                                        (auser.GetValue("phone") ?? "").ToString(),
                                        (auser.GetValue("city") ?? "").ToString(),

                                        (auser.GetValue("organization") ?? "").ToString(),
                                        reason,
                                        (auser.GetValue("lastLoggedIn") ?? "").ToString(),
                                        (auser.GetValue("joinedDate") ?? "").ToString(),
                                        (auser.GetValue("numberOfLogins") ?? "").ToString(),
                                        (auser.GetValue("dateApproved") ?? "").ToString(),
                                        (auser.GetValue("dateDenied") ?? "").ToString(),
                                        (auser.GetValue("dateInactive") ?? "").ToString(),
                                        auser.UpdateDate.ToString()

                                        ));
            }
            return(sb);
        }