Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7380


Ignore:
Timestamp:
01/20/12 13:24:10 (13 years ago)
Author:
ascheibe
Message:

#1648

  • fixed user query ws methods
  • improved user view
Location:
branches/ClientUserManagement
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/AccessClient.cs

    r7375 r7380  
    9393
    9494    public static void Store(IAccessItem item) {
    95       //TODO: never used? delete?
     95      //TODO: prevent storing of lightweight users
    9696    }
    9797
  • branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/Views/LightweightUserView.cs

    r7375 r7380  
    3131
    3232  [View("LightweightUser View")]
    33   [Content(typeof(CheckedItemList<LightweightUser>), true)]
     33  [Content(typeof(ReadOnlyCheckedItemList<LightweightUser>), true)]
    3434  public partial class LightweightUserView : CheckedItemListView<LightweightUser> {
    3535    public LightweightUserView() {
    3636      InitializeComponent();
    3737      this.showDetailsCheckBox.Checked = false;
     38      this.itemsGroupBox.Text = "Users";
    3839    }
    3940
    4041    protected override void SetEnabledStateOfControls() {
    4142      base.SetEnabledStateOfControls();
    42       this.addButton.Enabled = false;
    4343      this.showDetailsCheckBox.Enabled = false;
    44       this.removeButton.Enabled = false;
    45     }
    46 
    47     protected override void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
    48       base.itemsListView_SelectedIndexChanged(sender, e);
    49       this.removeButton.Enabled = false;
    5044    }
    5145
  • branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/Views/RefreshableLightweightUserView.cs

    r7375 r7380  
    3434    public RefreshableLightweightUserView() {
    3535      InitializeComponent();
    36 
    3736    }
    3837
    39     //set an action like a webservice call to retrieve the users which should be marked as checked       
    40     //TODO: disable refresh button if not set
     38    //set an action like a webservice call to retrieve the users which should be marked as checked           
    4139    public Func<List<Guid>> FetchSelectedUsers { get; set; }
    4240    private List<Guid> selectedUsers;
     
    6462        checkedUsers.SetItemCheckedState(idx, selectedUsers.Contains(u.Id));
    6563      });
    66       lightweightUserView.Content = checkedUsers;
     64      lightweightUserView.Content = checkedUsers.AsReadOnly();
     65    }
     66
     67    protected override void SetEnabledStateOfControls() {
     68      base.SetEnabledStateOfControls();
     69      refreshButton.Enabled = FetchSelectedUsers != null;
    6770    }
    6871
    6972    public ICheckedItemList<LightweightUser> GetCheckedUsers() {
    70       if (lightweightUserView.Content == null)
    71         return null;
    72       else
    73         return lightweightUserView.Content;
     73      return (lightweightUserView.Content == null) ? null : lightweightUserView.Content;
    7474    }
    7575
  • branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/Views/RefreshableView.cs

    r7368 r7380  
    4949    }
    5050
    51 
    52     protected override void OnContentChanged() {
    53       base.OnContentChanged();
    54       if (Content == null) {
    55         //TODO: remove?
    56       } else {
    57 
    58       }
    59     }
    60 
    6151    protected override void SetEnabledStateOfControls() {
    6252      base.SetEnabledStateOfControls();
  • branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/AccessService.cs

    r7368 r7380  
    278278      DA.User accessUser = null;
    279279
    280       using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
    281         var query = from u in context.UserGroupBases.OfType<DA.User>()
    282                     where u.Id == userId
    283                     select u;
    284         if (query.Count() == 1) {
    285           accessUser = query.First();
    286         } else {
    287           //if the user is not in the access db at it
    288           DA.User user = new DA.User();
    289           user.Id = userId;
    290           user.FullName = "Not set";
    291           context.UserGroupBases.InsertOnSubmit(user);
    292           context.SubmitChanges();
    293           accessUser = user;
    294         }
    295       }
    296 
    297280      using (DA.ASPNETAuthenticationDataContext context = new DA.ASPNETAuthenticationDataContext()) {
    298281        var userQuery = from u in context.aspnet_Users
     
    311294      }
    312295
     296      if (aspUser == null || aspMembership == null) {
     297        using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
     298          var query = from u in context.UserGroupBases.OfType<DA.User>()
     299                      where u.Id == userId
     300                      select u;
     301          if (query.Count() == 1) {
     302            accessUser = query.First();
     303          } else {
     304            //if the user is not in the access db add it (this makes it easy to upgrade with an existing asp.net authentication db)
     305            DA.User user = new DA.User();
     306            user.Id = userId;
     307            user.FullName = "Not set";
     308            context.UserGroupBases.InsertOnSubmit(user);
     309            context.SubmitChanges();
     310            accessUser = user;
     311          }
     312        }
     313      }
     314
    313315      if (aspUser == null || aspMembership == null || accessUser == null) {
    314         //TODO: error handling
    315         return null;
     316        throw new Exception("User with id " + userId + " not found.");
    316317      } else {
    317318        return Convert.ToDto(accessUser, aspUser, aspMembership);
     
    332333      }
    333334
    334       using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
    335         var query = from u in context.UserGroupBases.OfType<DA.User>()
    336                     where u.Id == userId
    337                     select u;
    338         if (query.Count() == 1) {
    339           accessUser = query.First();
    340         } else {
    341           //if the user is not in the access db at it
    342           DA.User user = new DA.User();
    343           user.Id = userId;
    344           user.FullName = "Not set";
    345           context.UserGroupBases.InsertOnSubmit(user);
    346           context.SubmitChanges();
    347           accessUser = user;
     335      if (aspUser != null) {
     336        using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
     337          var query = from u in context.UserGroupBases.OfType<DA.User>()
     338                      where u.Id == userId
     339                      select u;
     340          if (query.Count() == 1) {
     341            accessUser = query.First();
     342          } else {
     343            //if the user is not in the access db add it (this makes it easy to upgrade with an existing asp.net authentication db)
     344            DA.User user = new DA.User();
     345            user.Id = userId;
     346            user.FullName = "Not set";
     347            context.UserGroupBases.InsertOnSubmit(user);
     348            context.SubmitChanges();
     349            accessUser = user;
     350          }
    348351        }
    349352      }
    350353
    351354      if (aspUser == null || accessUser == null) {
    352         //TODO: error handling
    353         return null;
     355        throw new Exception("User with id " + userId + " not found.");
    354356      } else {
    355357        return Convert.ToDto(accessUser, aspUser);
     
    365367      List<Guid> accessUserGuids = null;
    366368
    367       using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
    368         var query = from u in context.UserGroupBases.OfType<DA.User>()
    369                     select u.Id;
     369      using (DA.ASPNETAuthenticationDataContext context = new DA.ASPNETAuthenticationDataContext()) {
     370        var query = from u in context.aspnet_Users
     371                    select u.UserId;
    370372        accessUserGuids = query.ToList();
    371373      }
    372 
    373374      return accessUserGuids.Select(x => BuildLightweightUserDto(x));
    374375    }
     
    377378      List<Guid> accessUserGuids = null;
    378379
    379       using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
    380         var query = from u in context.UserGroupBases.OfType<DA.User>()
    381                     select u.Id;
     380      using (DA.ASPNETAuthenticationDataContext context = new DA.ASPNETAuthenticationDataContext()) {
     381        var query = from u in context.aspnet_Users
     382                    select u.UserId;
    382383        accessUserGuids = query.ToList();
    383384      }
Note: See TracChangeset for help on using the changeset viewer.