public async Task <Table[]> InheritAsync(Authentication authentication, Table table, string newTableName, string categoryPath, bool copyContent) { try { this.ValidateExpired(); var path = await this.Dispatcher.InvokeAsync(() => { this.CremaHost.DebugMethod(authentication, this, nameof(InheritAsync), this, table, newTableName, categoryPath, copyContent); this.ValidateInherit(authentication, table, newTableName, categoryPath, copyContent); return(table.Path); }); var taskID = GuidUtility.FromName(nameof(InheritAsync) + categoryPath + newTableName + copyContent); var itemName = new ItemName(path); var targetName = new ItemName(categoryPath, newTableName); var dataSet = await table.ReadDataForCopyAsync(authentication, categoryPath); var dataTable = dataSet.Tables[itemName.Name, itemName.CategoryPath]; var dataTables = dataSet.Tables.ToArray(); var newDataTable = dataTable.Inherit(targetName, copyContent); newDataTable.CategoryPath = categoryPath; using var dataBaseSet = await DataBaseSet.CreateAsync(this.DataBase, dataSet, DataBaseSetOptions.AllowTableCreation); var tables = await this.AddNewAsync(authentication, dataBaseSet); await this.Dispatcher.InvokeAsync(() => this.DataBase.InvokeTaskCompletedEvent(authentication, taskID)); return(tables); } catch (Exception e) { this.CremaHost.Error(e); throw; } }
public async Task <Table[]> InheritAsync(Authentication authentication, Table table, string newTableName, string categoryPath, bool copyContent) { try { this.ValidateExpired(); var name = await this.Dispatcher.InvokeAsync(() => { this.CremaHost.DebugMethod(authentication, this, nameof(InheritAsync), this, table, newTableName, categoryPath, copyContent); return(table.Name); }); var taskID = GuidUtility.FromName(nameof(InheritAsync) + categoryPath + newTableName + copyContent); var result = await this.Service.InheritTableAsync(authentication.Token, name, newTableName, categoryPath, copyContent); var tableInfos = result.Value; await this.DataBase.WaitAsync(taskID); return(await this.Dispatcher.InvokeAsync(() => tableInfos.Select(item => this[item.Name]).ToArray())); } catch (Exception e) { this.CremaHost.Error(e); throw; } }
//[Obsolete("for 2.0")] /// <summary> /// for version 2.0 /// </summary> private void ReadTableInfoVersion2(XmlSchemaComplexType complexType, CremaDataTable dataTable) { string textValue; dataTable.InternalCreationInfo = complexType.ReadAppInfoAsSigunatureDate(CremaSchema.TableInfo, CremaSchemaObsolete.CreatorObsolete, CremaSchema.CreatedDateTime); dataTable.InternalModificationInfo = complexType.ReadAppInfoAsSigunatureDate(CremaSchema.TableInfo, CremaSchema.Modifier, CremaSchema.ModifiedDateTime); textValue = complexType.ReadAppInfoAsString(CremaSchema.TableInfo, CremaSchema.ID); if (textValue != null) { dataTable.InternalTableID = Guid.Parse(textValue); } else { dataTable.InternalTableID = GuidUtility.FromName(dataTable.Name); } dataTable.InternalTags = complexType.ReadAppInfoAsTagInfo(CremaSchema.TableInfo, CremaSchema.Tags); dataTable.InternalComment = complexType.ReadDescription(); var properties = new PropertyCollection(); this.ReadExtendedProperties(complexType, properties); if (properties.ContainsKey(CremaSchemaObsolete.DataLocation) == true) { dataTable.InternalTags = new TagInfo(properties[CremaSchemaObsolete.DataLocation] as string); properties.Remove(CremaSchemaObsolete.DataLocation); } }
protected AuthenticatorBase() { if (this.GetType().Attributes.HasFlag(TypeAttributes.Public) == true) { throw new InvalidOperationException(Resources.Exception_NotAllowedAsPublic); } this.name = this.GetType().Assembly.FullName; this.pluginID = GuidUtility.FromName(name); }
public async Task <TypeCategory> AddNewAsync(Authentication authentication, string name, string parentPath) { try { if (authentication is null) { throw new ArgumentNullException(nameof(authentication)); } if (authentication.IsExpired == true) { throw new AuthenticationExpiredException(nameof(authentication)); } if (name is null) { throw new ArgumentNullException(nameof(name)); } if (parentPath is null) { throw new ArgumentNullException(nameof(parentPath)); } this.ValidateExpired(); var categoryName = await this.Dispatcher.InvokeAsync(() => { this.CremaHost.DebugMethod(authentication, this, nameof(AddNewAsync), this, name, parentPath); this.ValidateAddNew(authentication, name, parentPath); return(new CategoryName(parentPath, name)); }); var taskID = GuidUtility.FromName(categoryName); var fullPaths = new string[] { PathUtility.Separator + CremaSchema.TypeDirectory + categoryName }; await this.Repository.LockAsync(authentication, this, nameof(AddNewAsync), fullPaths); using var dataBaseSet = await DataBaseSet.CreateEmptyAsync(this.DataBase, fullPaths); await this.InvokeCategoryCreateAsync(authentication, categoryName); var result = await this.Dispatcher.InvokeAsync(() => { this.CremaHost.Sign(authentication); var category = this.BaseAddNew(name, parentPath, authentication); var items = EnumerableUtility.One(category).ToArray(); this.InvokeCategoriesCreatedEvent(authentication, items); return(category); }); await this.Dispatcher.InvokeAsync(() => this.DataBase.InvokeTaskCompletedEvent(authentication, taskID)); return(result); } catch (Exception e) { this.CremaHost.Error(e); throw; } }
//[Obsolete("for 2.0")] internal static Guid ReadAppInfoAsGuidVersion2(this XmlSchemaAnnotated annotated, string nodeName, string attributeName, string nameToGenerate) { var text = ReadAppInfoAsString(annotated, nodeName, attributeName); if (string.IsNullOrEmpty(text) == true) { return(GuidUtility.FromName(nameToGenerate)); } return(Guid.Parse(text)); }
public async Task LoginAsync(Guid authenticationToken) { var taskID = GuidUtility.FromName($"{authenticationToken}"); await this.Dispatcher.InvokeAsync(() => { this.Authentication = new Authentication(new UserAuthenticationProvider(this), authenticationToken); }); await this.Context.WaitAsync(taskID); }
protected AuthenticatorBase(string name) { if (this.GetType().Attributes.HasFlag(TypeAttributes.Public) == false) { throw new InvalidOperationException(Resources.Exception_NotAllowedAsPublic); } this.name = name ?? throw new ArgumentNullException(nameof(name)); if (this.name == string.Empty) { throw new ArgumentException(Resources.Exception_InvalidName); } this.pluginID = GuidUtility.FromName(name); }
public RepositoryInfo GetRepositoryInfo(string basePath, string repositoryName) { var uri = this.GetUrl(basePath, repositoryName); var latestLog = SvnLogInfo.GetLatestLog($"{uri}"); var firstLog = SvnLogInfo.GetFirstLog($"{uri}"); var repositoryInfo = new RepositoryInfo() { ID = GuidUtility.FromName(repositoryName + firstLog.Revision), Name = repositoryName, Comment = firstLog.Comment, Revision = latestLog.Revision, CreationInfo = new SignatureDate(firstLog.Author, firstLog.DateTime), ModificationInfo = new SignatureDate(latestLog.Author, latestLog.DateTime), }; return(repositoryInfo); }
public async Task <Type> CopyAsync(Authentication authentication, string typeName, string newTypeName, string categoryPath) { try { this.ValidateExpired(); var tuple = await this.Dispatcher.InvokeAsync(() => { this.CremaHost.DebugMethod(authentication, this, nameof(CopyAsync), typeName, newTypeName, categoryPath); this.ValidateCopy(authentication, typeName, newTypeName); return(this[typeName], this[typeName].Path); }); var type = tuple.Item1; var path = tuple.Path; var taskID = GuidUtility.FromName(categoryPath + newTypeName); var itemName = new ItemName(tuple.Path); var targetName = new ItemName(categoryPath, newTypeName); var dataSet = await type.ReadDataForCopyAsync(authentication, categoryPath); var dataType = dataSet.Types[itemName.Name, itemName.CategoryPath]; var newDataType = dataType.Copy(targetName); using var dataBaseSet = await DataBaseSet.CreateAsync(this.DataBase, dataSet, DataBaseSetOptions.AllowTypeCreation); var typePaths = new string[] { categoryPath + newTypeName }; await this.InvokeTypeCreateAsync(authentication, typePaths, dataBaseSet); var result = await this.Dispatcher.InvokeAsync(() => { this.CremaHost.Sign(authentication); var newType = this.BaseAddNew(newTypeName, categoryPath, authentication); newType.Initialize(newDataType.TypeInfo); this.InvokeTypesCreatedEvent(authentication, new Type[] { newType }, dataSet); this.DataBase.InvokeTaskCompletedEvent(authentication, taskID); return(newType); }); return(result); } catch (Exception e) { this.CremaHost.Error(e); throw; } }
public async Task <DataBase> AddNewDataBaseAsync(Authentication authentication, string dataBaseName, string comment) { try { await this.Dispatcher.InvokeAsync(() => { this.CremaHost.DebugMethod(authentication, this, nameof(AddNewDataBaseAsync), dataBaseName, comment); }); var taskID = GuidUtility.FromName(dataBaseName + comment); var result = await this.Service.CreateAsync(authentication.Token, dataBaseName, comment); await this.WaitAsync(taskID); return(await this.Dispatcher.InvokeAsync(() => this[dataBaseName])); } catch (Exception e) { this.CremaHost.Error(e); throw; } }
public async Task <DataBase> CloneDataBaseAsync(Authentication authentication, DataBase dataBase, string newDataBaseName, string comment, string revision) { try { var name = await this.Dispatcher.InvokeAsync(() => { this.CremaHost.DebugMethod(authentication, this, nameof(CloneDataBaseAsync), dataBase, newDataBaseName, comment, revision); return(dataBase.Name); }); var taskID = GuidUtility.FromName(newDataBaseName + comment); var result = await this.Service.CopyAsync(authentication.Token, name, newDataBaseName, comment, revision); await this.WaitAsync(taskID); return(await this.Dispatcher.InvokeAsync(() => this[newDataBaseName])); } catch (Exception e) { this.CremaHost.Error(e); throw; } }
public async Task <TypeCategory> AddNewAsync(Authentication authentication, string name, string parentPath) { try { this.ValidateExpired(); var categoryName = await this.Dispatcher.InvokeAsync(() => { this.CremaHost.DebugMethod(authentication, this, nameof(AddNewAsync), this, name, parentPath); return(new CategoryName(parentPath, name)); }); var taskID = GuidUtility.FromName(categoryName); var result = await this.Service.NewTypeCategoryAsync(authentication.Token, categoryName); await this.DataBase.WaitAsync(taskID); return(await this.Dispatcher.InvokeAsync(() => this[categoryName])); } catch (Exception e) { this.CremaHost.Error(e); throw; } }
public async Task <Type> CopyAsync(Authentication authentication, string typeName, string newTypeName, string categoryPath) { try { this.ValidateExpired(); await this.Dispatcher.InvokeAsync(() => { this.CremaHost.DebugMethod(authentication, this, nameof(CopyAsync), typeName, newTypeName, categoryPath); }); var taskID = GuidUtility.FromName(categoryPath + newTypeName); var result = await this.Context.Service.CopyTypeAsync(authentication.Token, typeName, newTypeName, categoryPath); var typeInfo = result.Value; await this.DataBase.WaitAsync(taskID); return(await this.Dispatcher.InvokeAsync(() => this[typeInfo.Name, typeInfo.CategoryPath])); } catch (Exception e) { this.CremaHost.Error(e); throw; } }
public async Task <Guid> LoginAsync(SecureString password) { try { if (password is null) { throw new ArgumentNullException(nameof(password)); } this.ValidateExpired(); return(await this.Dispatcher.InvokeAsync(() => { this.CremaHost.DebugMethod(Authentication.System, this, nameof(LoginAsync), this); this.ValidateLogin(password); var users = new User[] { this }; var authentication = new Authentication(new UserAuthenticationProvider(this), Guid.NewGuid()); var taskID = GuidUtility.FromName($"{authentication.Token}"); if (this.Authentication != null) { throw new CremaException("b722d687-0a8d-4999-ad54-cf38c0c25d6f"); } this.Authentication = authentication; this.IsOnline = true; this.CremaHost.Sign(authentication); this.Container.InvokeUsersStateChangedEvent(this.Authentication, users); this.Container.InvokeUsersLoggedInEvent(this.Authentication, users); this.Context.InvokeTaskCompletedEvent(authentication, taskID); return this.Authentication.Token; })); } catch (Exception e) { this.CremaHost.Error(e); throw; } }