public async static Task <bool> UnloadAsync(Authentication authentication, IDataBaseDescriptor descriptor) { if (descriptor.Target is IDataBase dataBase) { try { if (descriptor.AuthenticationInfos.Any() == true && await AppMessageBox.ShowProceedAsync(Resources.Message_VerifyToCloseDataBase) == false) { return(false); } await dataBase.UnloadAsync(authentication); return(true); } catch (Exception e) { await AppMessageBox.ShowErrorAsync(e); return(false); } } else { throw new NotImplementedException(); } }
public async static Task <bool> DeleteAsync(Authentication authentication, IDataBaseDescriptor descriptor) { if (descriptor.Target is IDataBase dataBase) { if (await new DeleteViewModel().ShowDialogAsync() != true) { return(false); } try { await dataBase.DeleteAsync(authentication); await AppMessageBox.ShowAsync(Resources.Message_Deleted); return(true); } catch (Exception e) { await AppMessageBox.ShowErrorAsync(e); return(false); } } else { throw new NotImplementedException(); } }
public static bool CanViewLog(Authentication authentication, IDataBaseDescriptor descriptor) { if (descriptor is IPermissionDescriptor permissionDescriptor) { return(permissionDescriptor.AccessType >= AccessType.Guest); } return(false); }
public static bool CanDelete(Authentication authentication, IDataBaseDescriptor descriptor) { if (DataBaseDescriptorUtility.IsLoaded(authentication, descriptor) == true) { return(false); } return(authentication.Authority == Authority.Admin); }
public async static Task <string> RenameAsync(Authentication authentication, IDataBaseDescriptor descriptor) { var dialog = await RenameDataBaseViewModel.CreateInstanceAsync(authentication, descriptor); if (await dialog?.ShowDialogAsync() == true) { return(dialog.NewName); } return(null); }
public static bool CanLoad(Authentication authentication, IDataBaseDescriptor descriptor) { if (DataBaseDescriptorUtility.IsLoaded(authentication, descriptor) == true) { return(false); } if (descriptor is IAccessibleDescriptor accessibleDescriptor) { return(AccessibleDescriptorUtility.IsPrivate(authentication, accessibleDescriptor) == false && authentication.Authority == Authority.Admin); } return(authentication.Authority == Authority.Admin); }
public static bool CanUnload(Authentication authentication, IDataBaseDescriptor descriptor) { if (DataBaseDescriptorUtility.IsLoaded(authentication, descriptor) == false) { return(false); } if (descriptor is IPermissionDescriptor permissionDescriptor) { return(permissionDescriptor.AccessType >= AccessType.Owner); } return(authentication.Authority == Authority.Admin); }
public static bool IsLoaded(Authentication authentication, IDataBaseDescriptor descriptor) { if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (authentication == null) { return(false); } return(descriptor.DataBaseState.HasFlag(DataBaseState.IsLoaded)); }
public override void SelectObject(object obj) { if (this.notifyObject != null) { this.notifyObject.PropertyChanged -= NotifyObject_PropertyChanged; } this.descriptor = obj as IDataBaseDescriptor; this.notifyObject = obj as INotifyPropertyChanged; this.SyncUsers(this.descriptor == null ? new AuthenticationInfo[] { } : this.descriptor.AuthenticationInfos); if (this.notifyObject != null) { this.notifyObject.PropertyChanged += NotifyObject_PropertyChanged; } }
public async static Task <bool> LoadAsync(Authentication authentication, IDataBaseDescriptor descriptor) { if (descriptor.Target is IDataBase dataBase) { try { await dataBase.Dispatcher.InvokeAsync(() => dataBase.Load(authentication)); return(true); } catch (Exception e) { AppMessageBox.ShowError(e); return(false); } } else { throw new NotImplementedException(); } }
public override void SelectObject(object obj) { this.descriptor = obj as IDataBaseDescriptor; if (this.descriptor != null) { foreach (var item in this.domains) { item.IsVisible = this.descriptor.DataBaseID == item.DomainInfo.DataBaseID; } } else { foreach (var item in this.domains) { item.IsVisible = false; } } this.SelectedDomain = null; this.NotifyOfPropertyChange(nameof(this.IsVisible)); this.NotifyOfPropertyChange(nameof(this.SelectedObject)); }
public static Task <RenameDataBaseViewModel> CreateInstanceAsync(Authentication authentication, IDataBaseDescriptor descriptor) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (descriptor.Target is IDataBase dataBase) { return(dataBase.Dispatcher.InvokeAsync(() => { return new RenameDataBaseViewModel(authentication, dataBase); })); } else { throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor)); } }
public override void SelectObject(object obj) { this.Detach(); this.descriptor = obj as IDataBaseDescriptor; this.Attach(); }
public DataBaseDescriptor(Authentication authentication, IDataBaseDescriptor descriptor, bool isSubscriptable, object owner) : base(authentication, descriptor.Target, descriptor, isSubscriptable) { this.dataBase = descriptor.Target; this.owner = owner ?? this; }
public static async Task <LogViewModel> ShowDialogAsync(Authentication authentication, IDataBaseDescriptor descriptor) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (descriptor.Target is IDataBase dataBase) { try { var dialog = await dataBase.Dispatcher.InvokeAsync(() => new LogViewModel(authentication, dataBase)); if (dialog.ShowDialog() == true) { return(dialog); } return(null); } catch (Exception e) { CremaLog.Error(e); return(null); } } throw new NotImplementedException(); }
public DataBaseItemViewModel(Authentication authentication, IDataBaseDescriptor descriptor, object owner) : base(authentication, new DataBaseDescriptor(authentication, descriptor, false, owner), owner) { }
public async static Task <bool> CopyAsync(Authentication authentication, IDataBaseDescriptor descriptor) { var dialog = await CopyDataBaseViewModel.CreateInstanceAsync(authentication, descriptor); return(await dialog?.ShowDialogAsync() == true); }
public static async Task <bool> ViewLogAsync(Authentication authentication, IDataBaseDescriptor descriptor) { return(await LogViewModel.ShowDialogAsync(authentication, descriptor) != null); }
public static bool CanCopy(Authentication authentication, IDataBaseDescriptor descriptor) { return(authentication.Authority == Authority.Admin); }