public override async void Edit <T>(T CurrentUser) { if (!this.GetButtonAuth(Authority.EDIT)) { return; } if (CurrentUser != null) { try { UserDialogViewModel view = new UserDialogViewModel(); view.Title = Configuration.USER_EDIT_TITLE; var request = await ZFSBridge.BridgeFactory.BridgeManager.GetUserManager().GetModelByAccount((CurrentUser as tb_User).Account); view.User = request.Results; view.User.Password = CEncoder.Decode(view.User.Password);/*解密*/ var dialog = ServiceProvider.Instance.Get <IModelDialog>("UserViewDlg"); dialog.BindViewModel(view); var taskResult = await dialog.ShowDialog( null, view.ExtendedClosingEventHandler); if (taskResult) { ZFSInterface.User.IUser userSerivce = await Task.Run(() => ZFSBridge.BridgeFactory.BridgeManager.GetUserManager()); view.User.Password = CEncoder.Encode(view.User.Password);/*加密*/ var req = await userSerivce.UpdateEntity(view.User); if (req.Success) { var mod = GridModelList.FirstOrDefault(t => t.isid.Equals(view.User.isid)); GridModelList.Remove(mod); GridModelList.Add(view.User); Msg.Info(Configuration.ADD_MSG); } } } catch (Exception ex) { Msg.Error(ex.Message, false); } } }
public override async void Add <T>(T obj) { UserDialogViewModel viewModel = new UserDialogViewModel(); viewModel.Title = Configuration.USER_ADD_TITLE; var dialog = ServiceProvider.Instance.Get <IModelDialog>("UserViewDlg"); dialog.BindViewModel(viewModel); var taskResult = await dialog.ShowDialog( null, viewModel.ExtendedClosingEventHandler); if (taskResult) { try { ZFSInterface.User.IUser userSerivce = ZFSBridge.BridgeFactory.BridgeManager.GetUserManager(); viewModel.User.Password = CEncoder.Encode(viewModel.User.Password);/*加密*/ viewModel.User.IsLocked = 0; viewModel.User.FlagAdmin = "0"; viewModel.User.FlagOnline = "0"; viewModel.User.LoginCounter = 0; viewModel.User.CreateTime = DateTime.Now; var req = await userSerivce.AddEntity(viewModel.User); if (req.Success) { GridModelList.Add(viewModel.User); Msg.Info(Configuration.ADD_MSG); } } catch (Exception ex) { Msg.Error(ex.Message, false); } } }