• Membership的一些随笔


     Guid CreateUser(string username, string password, string email, string comment, string passwordQuestion, string passwordAnswer, bool isApproved, ProfileData profileData, IList<string> roles, IList<string> permissions, IList<Guid> companies, out MembershipCreateStatus status);

     


    membershipApi.CreateUser(this.TextBoxUserName.Text.Trim(), this.TextBoxPassword.Text.Trim(), this.TextBoxEmail.Text, this.TextBoxComment.Text, null, null, true, profile, new[] { BH.Roles.网站用户 }, null, new Guid[] { companyId }, out createStatus);

    using (TransactionScope ts = new TransactionScope())
       {
        try
        {
         Guid companyId = membershipApi.CreateCompany(null, this.TextBoxCompanyName.Text, BH.CompanyTypes.网站用户, null, CompanyStatus.Enabled, null, new EntityElement(BH.EntityTypes.注册企业));
         MembershipCreateStatus createStatus;
         GenericProfileData profile = new GenericProfileData()
         {
           Phone = this.TextBoxPhone.Text
         };
         membershipApi.CreateUser(this.TextBoxUserName.Text.Trim(), this.TextBoxPassword.Text.Trim(), this.TextBoxEmail.Text, this.TextBoxComment.Text, null, null, true, profile, new[] { BH.Roles.网站用户 }, null, new Guid[] { companyId }, out createStatus);
         ts.Complete();
        }
        catch (InvalidOperationException exp)
        {
         this.MessagePanel.ShowWarning(exp.Message);
         return;
        }
        catch (Exception exp)
        {
         this.MessagePanel.ShowError(exp);
         Logger.Instance(this).Error(exp);
         return;
        }
       }

     

     

     

     

    UserStatus userStatus = (UserStatus)Enum.Parse(typeof(UserStatus), this.RadioButtonByUserStatus.SelectedValue);

       int recordsCount;
       var userElements = MembershipApi.FindUsers(this.TextBoxQueryByAgencyName.Text, null, userTypes.ToArray(), this.TextBoxQueryByUserName.Text, userStatus, pageIndex, this.Pager.PageSize, out recordsCount);
       this.RepeaterUsers.DataSource = userElements;
       this.RepeaterUsers.DataBind();

       this.LabelRecordCount.Text = recordsCount.ToString();
       this.Pager.RecordCount = recordsCount;
       this.Pager.CurrentPageIndex = pageIndex + 1;
       this.Pager.DataBind();

     

     

     

     

     

  • 相关阅读:
    Android基础学习之context
    [原]C语言实现的快速排序,采用分治策略,递归实现
    [原]动态获取应用的视图实际大小
    [原]此程序专用来说明C++模板的用法
    [原]C++程序示例:涉及到抽象类、继承…
    [原]C++关于运算符重载的程序报错error…
    [原]用C#模拟实现扑克牌发牌、排序程序…
    [原]用C#模拟实现扑克牌发牌、排序程序。
    Come on , Android 常用开发工具
    ADB 常用命令
  • 原文地址:https://www.cnblogs.com/duwamish/p/1342263.html
Copyright © 2020-2023  润新知