/// <summary> /// /// </summary> /// <param name="obj"></param> protected WfOguObject(IOguObject obj, SchemaType st) { ExceptionHelper.FalseThrow<ArgumentNullException>(obj != null, "obj"); this.id = obj.ID; this.baseObject = obj; this.objectType = st; }
public override DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType) { if (SelectCommand != null) { InnerDataAdapter.SelectCommand = RetrieveBaseType(SelectCommand); } return InnerDataAdapter.FillSchema(dataSet, schemaType); }
public Parser(SchemaType schemaType, XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler) { this.schemaType = schemaType; this.nameTable = nameTable; this.schemaNames = schemaNames; this.eventHandler = eventHandler; this.xmlResolver = new XmlUrlResolver(); processMarkup = true; dummyDocument = new XmlDocument(); }
public Parser(SchemaType schemaType, XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler) { this.schemaType = schemaType; this.nameTable = nameTable; this.schemaNames = schemaNames; this.eventHandler = eventHandler; this.xmlResolver = System.Xml.XmlConfiguration.XmlReaderSection.CreateDefaultResolver(); processMarkup = true; dummyDocument = new XmlDocument(); }
public override DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType) { if (SelectCommand != null) { InnerDataAdapter.SelectCommand = ((GlimpseDbCommand)SelectCommand).Inner; } return InnerDataAdapter.FillSchema(dataSet, schemaType); }
public Parser(SchemaType schemaType, XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler) { _schemaType = schemaType; _nameTable = nameTable; _schemaNames = schemaNames; _eventHandler = eventHandler; _xmlResolver = null; _processMarkup = true; _dummyDocument = new XmlDocument(); }
private bool CheckSchemaRoot(SchemaType rootType, out string code) { code = null; if (this.schemaType == SchemaType.None) { this.schemaType = rootType; } switch (rootType) { case SchemaType.None: case SchemaType.DTD: code = "Sch_SchemaRootExpected"; if (this.schemaType == SchemaType.XSD) { code = "Sch_XSDSchemaRootExpected"; } return false; case SchemaType.XDR: if (this.schemaType != SchemaType.XSD) { if (this.schemaType != SchemaType.XDR) { code = "Sch_MixSchemaTypes"; return false; } break; } code = "Sch_XSDSchemaOnly"; return false; case SchemaType.XSD: if (this.schemaType == SchemaType.XSD) { break; } code = "Sch_MixSchemaTypes"; return false; } return true; }
protected virtual void ExtractOguObject(IDictionary<string, object> dictionary, out SchemaType oguType, out OguBase result) { string id = (string)dictionary["id"]; oguType = SchemaType.Users; if (dictionary.ContainsKey("objectType")) oguType = (SchemaType)dictionary["objectType"]; result = CreateOguObject(oguType, id); result.Description = DictionaryHelper.GetValue(dictionary, "description", string.Empty); result.DisplayName = DictionaryHelper.GetValue(dictionary, "displayName", string.Empty); result.FullPath = DictionaryHelper.GetValue(dictionary, "fullPath", string.Empty); result.GlobalSortID = DictionaryHelper.GetValue(dictionary, "globalSortID", string.Empty); result.Name = DictionaryHelper.GetValue(dictionary, "name", string.Empty); result.SortID = DictionaryHelper.GetValue(dictionary, "sortID", string.Empty); result.Tag = DictionaryHelper.GetValue(dictionary, "tag", string.Empty); result.ClientContext = DictionaryHelper.GetValue(dictionary, "clientContext", (Dictionary<string, object>)null); if (dictionary.ContainsKey("status")) result.Properties["STATUS"] = DictionaryHelper.GetValue(dictionary, "status", 1); }
private static OguAndADObjectSetterBase GetSetter(ObjectModifyType modifyType, SchemaType schemaType) { string schemaTypeName = schemaType.ToString(); string cacheKey = "OguAndADObjectSetterBase" + "-" + modifyType.ToString() + "+" + schemaTypeName; return (OguAndADObjectSetterBase)ObjectContextCache.Instance.GetOrAddNewValue(cacheKey, (cache, key) => { SchemaMappingInfo mappingInfo = PermissionCenterToADSynchronizeSettings.GetConfig().SchemaMappings.GetSchemaMappingInfo(schemaTypeName); OguAndADObjectSetterBase setter = null; if (mappingInfo.ModifyOperations.ContainsKey(modifyType.ToString())) { SetterObjectMappingConfigurationElement objSetterMappingElement = mappingInfo.ModifyOperations[modifyType.ToString()]; setter = (OguAndADObjectSetterBase)PropertySettersSettings.GetConfig().ObjectSetters[objSetterMappingElement.OperationName].CreateInstance(); } cache.Add(cacheKey, setter); return setter; }); }
/// <summary> /// 创建机构人员组对象 /// </summary> /// <param name="type">需要创建的对象类型</param> /// <returns></returns> public IOguObject CreateObject(SchemaType type) { OguBaseImpl oBase = null; switch (type) { case SchemaType.Users: oBase = new OguUserImpl(); break; case SchemaType.Organizations: oBase = new OguOrganizationImpl(); break; case SchemaType.OrganizationsInRole: oBase = new OguOrganizationInRoleImpl(); break; case SchemaType.Groups: oBase = new OguGroupImpl(); break; default: throw new InvalidOperationException(string.Format(Resource.InvalidObjectTypeCreation, type.ToString())); } return oBase; }
public DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType) { DataTable[] dataTables; dataTables = new DataTable[dataSet.Tables.Count]; dataSet.Tables.CopyTo(dataTables, dataSet.Tables.Count); return dataTables; }
protected virtual OguBase CreateOguObject(SchemaType oguType, string id) { return (OguBase)OguBase.CreateWrapperObject(id, oguType); }
/// <summary> /// 返回数据库内所有表名称的XML格式字符串 /// </summary> /// <param name="st"></param> /// <param name="tablename"></param> /// <returns></returns> public string GetTableNames(SchemaType st = SchemaType.Tables, string tablename = "") { DataTable dt = new DataTable(); GetTableNames(ref dt, st, tablename); return TableToXMLString(dt, null); }
public virtual DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType) { DataTable[] array = new DataTable[dataSet.Tables.Count + 1]; dataSet.Tables.CopyTo(array, dataSet.Tables.Count); return(array); }
/// <summary> /// Async version of FillSchema /// </summary> /// <param name="dataSet">DataSet to use</param> /// <param name="schemaType">Schema Type</param> /// <returns>DataTable[]</returns> public Task <DataTable[]> FillSchemaAsync(DataSet dataSet, SchemaType schemaType) { return(FillSchemaAsync(dataSet, schemaType, CancellationToken.None)); }
public virtual DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType) { throw new NotSupportedException (); }
private bool CheckSchemaRoot(SchemaType rootType, out string code) { code = null; if (_schemaType == SchemaType.None) { _schemaType = rootType; } switch (rootType) { case SchemaType.XSD: if (_schemaType != SchemaType.XSD) { code = SR.Sch_MixSchemaTypes; return false; } break; case SchemaType.XDR: if (_schemaType == SchemaType.XSD) { code = SR.Sch_XSDSchemaOnly; return false; } else if (_schemaType != SchemaType.XDR) { code = SR.Sch_MixSchemaTypes; return false; } break; case SchemaType.DTD: //Did not detect schema type that can be parsed by this parser case SchemaType.None: code = SR.Sch_SchemaRootExpected; if (_schemaType == SchemaType.XSD) { code = SR.Sch_XSDSchemaRootExpected; } return false; default: Debug.Assert(false); break; } return true; }
public static Schema MixedSchema(SchemaType type = SchemaType.Default, bool withMetadata = true) { var componentId = DomainId.NewGuid(); var schema = new Schema("user", type: type) .Publish() .AddArray(101, "root-array", Partitioning.Language, f => f .AddAssets(201, "nested-assets") .AddBoolean(202, "nested-boolean") .AddDateTime(203, "nested-datetime") .AddGeolocation(204, "nested-geolocation") .AddJson(205, "nested-json") .AddJson(211, "nested-json2") .AddNumber(206, "nested-number") .AddReferences(207, "nested-references") .AddString(208, "nested-string") .AddTags(209, "nested-tags") .AddUI(210, "nested-ui")) .AddAssets(102, "root-assets", Partitioning.Invariant, new AssetsFieldProperties()) .AddBoolean(103, "root-boolean", Partitioning.Invariant, new BooleanFieldProperties()) .AddDateTime(104, "root-datetime", Partitioning.Invariant, new DateTimeFieldProperties { Editor = DateTimeFieldEditor.DateTime }) .AddDateTime(105, "root-date", Partitioning.Invariant, new DateTimeFieldProperties { Editor = DateTimeFieldEditor.Date }) .AddGeolocation(106, "root-geolocation", Partitioning.Invariant, new GeolocationFieldProperties()) .AddJson(107, "root-json", Partitioning.Invariant, new JsonFieldProperties()) .AddNumber(108, "root-number", Partitioning.Invariant, new NumberFieldProperties { MinValue = 1, MaxValue = 10 }) .AddReferences(109, "root-references", Partitioning.Invariant, new ReferencesFieldProperties()) .AddString(110, "root-string1", Partitioning.Invariant, new StringFieldProperties { Label = "My String1", IsRequired = true, AllowedValues = ImmutableList.Create("a", "b") }) .AddString(111, "root-string2", Partitioning.Invariant, new StringFieldProperties { Hints = "My String1" }) .AddTags(112, "root-tags", Partitioning.Language, new TagsFieldProperties()) .AddUI(113, "root-ui", Partitioning.Language, new UIFieldProperties()) .AddComponent(114, "root-component", Partitioning.Language, new ComponentFieldProperties { SchemaId = componentId }) .AddComponents(115, "root-components", Partitioning.Language, new ComponentsFieldProperties { SchemaId = componentId }) .Update(new SchemaProperties { Hints = "The User" }) .HideField(104) .HideField(211, 101) .DisableField(109) .DisableField(212, 101) .LockField(105); if (withMetadata) { schema.FieldsById[114].SetResolvedSchema(componentId, schema); schema.FieldsById[115].SetResolvedSchema(componentId, schema); } return(schema); }
private static ClientOguSchemaType ToClientOguSchemaType(this SchemaType schemaType) { return((ClientOguSchemaType)schemaType); }
/// <summary> /// Async version of FillSchema /// </summary> /// <param name="dataTable">DataTable to use</param> /// <param name="schemaType">Schema Type</param> /// <param name="command">DBCommand to use</param> /// <param name="behavior">Command Behavior</param> /// <returns>DataTable</returns> public Task <DataTable> FillSchemaAsync(DataTable dataTable, SchemaType schemaType, IDbCommand command, CommandBehavior behavior) { return(FillSchemaAsync(dataTable, schemaType, command, behavior, CancellationToken.None)); }
public virtual DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType) { throw ADP.NotSupported(); }
/// <summary> /// Async version of FillSchema /// </summary> /// <param name="dataTable">DataTable to use</param> /// <param name="schemaType">Schema Type</param> /// <param name="dataReader">DataReader to use</param> /// <returns>DataTable</returns> public Task <DataTable> FillSchemaAsync(DataTable dataTable, SchemaType schemaType, IDataReader dataReader) { return(FillSchemaAsync(dataTable, schemaType, dataReader, CancellationToken.None)); }
/// <summary> /// Async version of FillSchema /// </summary> /// <param name="dataSet">DataSet to use</param> /// <param name="schemaType">Schema Type</param> /// <param name="command">DBCommand to use</param> /// <param name="srcTable">Source Table</param> /// <param name="behavior">Command Behavior</param> /// <returns>DataTable[]</returns> public Task <DataTable[]> FillSchemaAsync(DataSet dataSet, SchemaType schemaType, IDbCommand command, string srcTable, CommandBehavior behavior) { return(FillSchemaAsync(dataSet, schemaType, command, srcTable, behavior, CancellationToken.None)); }
/// <summary> /// Async version of FillSchema /// </summary> /// <param name="dataSet">DataSet to use</param> /// <param name="schemaType">Schema Type</param> /// <param name="srcTable">Source Table</param> /// <param name="dataReader">DataReader to use</param> /// <returns>DataTable[]</returns> public Task <DataTable[]> FillSchemaAsync(DataSet dataSet, SchemaType schemaType, string srcTable, IDataReader dataReader) { return(FillSchemaAsync(dataSet, schemaType, srcTable, dataReader, CancellationToken.None)); }
/// <summary> /// Creates or Modifies the schema of the given DataTable based on the schema of /// the reader and the arguments passed. /// </summary> internal static int[] BuildSchema (IDataReader reader, DataTable table, SchemaType schemaType, MissingSchemaAction missingSchAction, MissingMappingAction missingMapAction, DataTableMappingCollection dtMapping ) { int readerIndex = 0; // FIXME : this fails if query has fewer columns than a table int[] mapping = new int[table.Columns.Count]; // mapping the reader indexes to the datatable indexes for(int i=0; i < mapping.Length; i++) { mapping[i] = -1; } ArrayList primaryKey = new ArrayList (); ArrayList sourceColumns = new ArrayList (); bool createPrimaryKey = true; DataTable schemaTable = reader.GetSchemaTable (); DataColumn ColumnNameCol = schemaTable.Columns["ColumnName"]; DataColumn DataTypeCol = schemaTable.Columns["DataType"]; DataColumn IsAutoIncrementCol = schemaTable.Columns["IsAutoIncrement"]; DataColumn AllowDBNullCol = schemaTable.Columns["AllowDBNull"]; DataColumn IsReadOnlyCol = schemaTable.Columns["IsReadOnly"]; DataColumn IsKeyCol = schemaTable.Columns["IsKey"]; DataColumn IsUniqueCol = schemaTable.Columns["IsUnique"]; DataColumn ColumnSizeCol = schemaTable.Columns["ColumnSize"]; foreach (DataRow schemaRow in schemaTable.Rows) { // generate a unique column name in the source table. string sourceColumnName; string realSourceColumnName ; if (ColumnNameCol == null || schemaRow.IsNull(ColumnNameCol) || (string)schemaRow [ColumnNameCol] == String.Empty) { sourceColumnName = DefaultSourceColumnName; realSourceColumnName = DefaultSourceColumnName + "1"; } else { sourceColumnName = (string) schemaRow [ColumnNameCol]; realSourceColumnName = sourceColumnName; } for (int i = 1; sourceColumns.Contains (realSourceColumnName); i += 1) realSourceColumnName = String.Format ("{0}{1}", sourceColumnName, i); sourceColumns.Add(realSourceColumnName); // generate DataSetColumnName from DataTableMapping, if any DataTableMapping tableMapping = null; //FIXME : The sourcetable name shud get passed as a parameter.. int index = dtMapping.IndexOfDataSetTable (table.TableName); string srcTable = (index != -1 ? dtMapping[index].SourceTable : table.TableName); tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction (dtMapping, srcTable, table.TableName, missingMapAction); if (tableMapping != null) { table.TableName = tableMapping.DataSetTable; // check to see if the column mapping exists DataColumnMapping columnMapping = DataColumnMappingCollection.GetColumnMappingBySchemaAction(tableMapping.ColumnMappings, realSourceColumnName, missingMapAction); if (columnMapping != null) { Type columnType = schemaRow[DataTypeCol] as Type; DataColumn col = columnType != null ? columnMapping.GetDataColumnBySchemaAction( table , columnType, missingSchAction) : null; if (col != null) { // if the column is not in the table - add it. if (table.Columns.IndexOf(col) == -1) { if (missingSchAction == MissingSchemaAction.Add || missingSchAction == MissingSchemaAction.AddWithKey) table.Columns.Add(col); int[] tmp = new int[mapping.Length + 1]; Array.Copy(mapping,0,tmp,0,col.Ordinal); Array.Copy(mapping,col.Ordinal,tmp,col.Ordinal + 1,mapping.Length - col.Ordinal); mapping = tmp; } if (missingSchAction == MissingSchemaAction.AddWithKey) { object value = (AllowDBNullCol != null) ? schemaRow[AllowDBNullCol] : null; bool allowDBNull = value is bool ? (bool)value : true; value = (IsKeyCol != null) ? schemaRow[IsKeyCol] : null; bool isKey = value is bool ? (bool)value : false; value = (IsAutoIncrementCol != null) ? schemaRow[IsAutoIncrementCol] : null; bool isAutoIncrement = value is bool ? (bool)value : false; value = (IsReadOnlyCol != null) ? schemaRow[IsReadOnlyCol] : null; bool isReadOnly = value is bool ? (bool)value : false; value = (IsUniqueCol != null) ? schemaRow[IsUniqueCol] : null; bool isUnique = value is bool ? (bool)value : false; col.AllowDBNull = allowDBNull; // fill woth key info if (isAutoIncrement && DataColumn.CanAutoIncrement(columnType)) { col.AutoIncrement = true; if (!allowDBNull) col.AllowDBNull = false; } if (columnType == DbTypes.TypeOfString) { col.MaxLength = (ColumnSizeCol != null) ? (int)schemaRow[ColumnSizeCol] : 0; } if (isReadOnly) col.ReadOnly = true; if (!allowDBNull && (!isReadOnly || isKey)) col.AllowDBNull = false; if (isUnique && !isKey && !columnType.IsArray) { col.Unique = true; if (!allowDBNull) col.AllowDBNull = false; } // This might not be set by all DataProviders bool isHidden = false; if (schemaTable.Columns.Contains ("IsHidden")) { value = schemaRow["IsHidden"]; isHidden = ((value is bool) ? (bool)value : false); } if (isKey && !isHidden) { primaryKey.Add (col); if (allowDBNull) createPrimaryKey = false; } } // add the ordinal of the column as a key and the index of the column in the datareader as a value. mapping[col.Ordinal] = readerIndex++; } } } } if (primaryKey.Count > 0) { DataColumn[] colKey = (DataColumn[])(primaryKey.ToArray(typeof (DataColumn))); if (createPrimaryKey) table.PrimaryKey = colKey; else { UniqueConstraint uConstraint = new UniqueConstraint(colKey); for (int i = 0; i < table.Constraints.Count; i++) { if (table.Constraints[i].Equals(uConstraint)) { uConstraint = null; break; } } if (uConstraint != null) table.Constraints.Add(uConstraint); } } return mapping; }
public IList<AttributeChange> GetChanges(string dn, ObjectModificationType modType, SchemaType type, object source) { List<AttributeChange> attributeChanges = new List<AttributeChange>(); CourseStudents students = source as CourseStudents; if (students == null) { GoogleCourse course = source as GoogleCourse; if (course == null) { throw new InvalidOperationException(); } else { students = course.Students; } } foreach (IAttributeAdapter typeDef in ManagementAgent.Schema[SchemaConstants.Course].AttributeAdapters.Where(t => t.Api == this.Api)) { foreach (string attributeName in typeDef.MmsAttributeNames) { if (type.HasAttribute(attributeName)) { attributeChanges.AddRange(typeDef.CreateAttributeChanges(dn, modType, students)); } } } return attributeChanges; }
protected virtual DataTable FillSchema (DataTable dataTable, SchemaType schemaType, IDataReader dataReader) { throw new NotImplementedException (); }
private List <AttributeChange> GetLocalChanges(string dn, ObjectModificationType modType, SchemaType type, object source) { List <AttributeChange> attributeChanges = new List <AttributeChange>(); Building building = source as Building; if (building == null) { throw new InvalidOperationException(); } foreach (IAttributeAdapter typeDef in this.SchemaType.AttributeAdapters.Where(t => t.Api == this.Api)) { if (typeDef.IsAnchor) { continue; } foreach (AttributeChange change in typeDef.CreateAttributeChanges(dn, modType, building)) { if (type.HasAttribute(change.Name)) { attributeChanges.Add(change); } } } return(attributeChanges); }
public IList <AttributeChange> GetChanges(string dn, ObjectModificationType modType, SchemaType type, object source) { List <AttributeChange> attributeChanges = this.GetLocalChanges(dn, modType, type, source); return(attributeChanges); }
protected virtual DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType, IDbCommand command, string srcTable, CommandBehavior behavior) { long logScopeId = DataCommonEventSource.Log.EnterScope("<comm.DbDataAdapter.FillSchema|API> {0}, dataSet, schemaType, command, srcTable, behavior={1}", ObjectID, behavior); try { if (null == dataSet) { throw ADP.ArgumentNull(nameof(dataSet)); } if ((SchemaType.Source != schemaType) && (SchemaType.Mapped != schemaType)) { throw ADP.InvalidSchemaType(schemaType); } if (string.IsNullOrEmpty(srcTable)) { throw ADP.FillSchemaRequiresSourceTableName(nameof(srcTable)); } if (null == command) { throw ADP.MissingSelectCommand(ADP.FillSchema); } return (DataTable[])FillSchemaInternal(dataSet, null, schemaType, command, srcTable, behavior); } finally { DataCommonEventSource.Log.ExitScope(logScopeId); } }
/// <summary>Creates a Swagger specification from a JSON string.</summary> /// <param name="data">The JSON data.</param> /// <param name="documentPath">The document path (URL or file path) for resolving relative document references.</param> /// <param name="expectedSchemaType">The expected schema type which is used when the type cannot be determined.</param> /// <returns>The <see cref="SwaggerDocument"/>.</returns> public static Task <SwaggerDocument> FromJsonAsync(string data, string documentPath, SchemaType expectedSchemaType) { return(FromJsonAsync(data, documentPath, expectedSchemaType, null)); }
private object FillSchemaInternal(DataSet dataset, DataTable datatable, SchemaType schemaType, IDbCommand command, string srcTable, CommandBehavior behavior) { object dataTables = null; bool restoreNullConnection = (null == command.Connection); try { IDbConnection activeConnection = DbDataAdapter.GetConnection3(this, command, ADP.FillSchema); ConnectionState originalState = ConnectionState.Open; try { QuietOpen(activeConnection, out originalState); using (IDataReader dataReader = command.ExecuteReader(behavior | CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo)) { if (null != datatable) { // delegate to next set of protected FillSchema methods dataTables = FillSchema(datatable, schemaType, dataReader); } else { dataTables = FillSchema(dataset, schemaType, srcTable, dataReader); } } } finally { QuietClose(activeConnection, originalState); } } finally { if (restoreNullConnection) { command.Transaction = null; command.Connection = null; } } return dataTables; }
public IList<AttributeChange> ApplyChanges(CSEntryChange csentry, SchemaType type, ref object target, bool patch = false) { Logger.WriteLine($"Processing students for course {csentry.DN}"); List<AttributeChange> changes = new List<AttributeChange>(); this.GetStudentChangesFromCSEntryChange(csentry, out CourseStudents studentsToAdd, out CourseStudents studentsToDelete, out CourseStudents reportedAdds, out CourseStudents reportedDeletes, csentry.ObjectModificationType == ObjectModificationType.Replace); HashSet<string> allStudentsToDelete = studentsToDelete.GetAllStudents(); List<Student> allStudentsToAdd = studentsToAdd.ToStudentList(); AttributeModificationType modificationType = csentry.ObjectModificationType == ObjectModificationType.Update ? AttributeModificationType.Update : AttributeModificationType.Add; try { if (csentry.ObjectModificationType != ObjectModificationType.Add && allStudentsToDelete.Count > 0) { try { this.config.ClassroomService.StudentFactory.RemoveStudents(csentry.DN, allStudentsToDelete.ToList(), false); foreach (string student in allStudentsToDelete) { Logger.WriteLine($"Deleted student {student} from course {csentry.DN}", LogLevel.Debug); } if (allStudentsToDelete.Count == 1) { Logger.WriteLine($"Deleted {allStudentsToDelete.Count} student from course {csentry.DN}"); } else { Logger.WriteLine($"Deleted {allStudentsToDelete.Count} students from course {csentry.DN}"); } } catch (AggregateCourseStudentException ex) { Logger.WriteLine("The following students removals failed"); foreach (Exception e in ex.Exceptions) { Logger.WriteException(e); } reportedDeletes.RemoveStudents(ex.FailedStudents); throw; } } if (allStudentsToAdd.Count > 0) { try { this.config.ClassroomService.StudentFactory.AddStudents(csentry.DN, allStudentsToAdd, false); foreach (Student student in allStudentsToAdd) { Logger.WriteLine($"Added student {student.UserId} to {csentry.DN}", LogLevel.Debug); } if (allStudentsToAdd.Count == 1) { Logger.WriteLine($"Added {allStudentsToAdd.Count} student to {csentry.DN}"); } else { Logger.WriteLine($"Added {allStudentsToAdd.Count} students to {csentry.DN}"); } } catch (AggregateCourseStudentException ex) { Logger.WriteLine("The following student additions failed"); foreach (Exception e in ex.Exceptions) { Logger.WriteException(e); } reportedAdds.RemoveStudents(ex.FailedStudents); throw; } } } finally { ApiInterfaceCourseStudents.AddAttributeChange(SchemaConstants.Students, modificationType, reportedDeletes.Students.ToValueChange(ValueModificationType.Delete), changes); ApiInterfaceCourseStudents.AddAttributeChange(SchemaConstants.Students, modificationType, reportedAdds.Students.ToValueChange(ValueModificationType.Add), changes); } Logger.WriteLine($"Processed students for course {csentry.DN}"); return changes; }
public DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType) { throw new NotImplementedException(); }
public IList <AttributeChange> GetChanges(string dn, ObjectModificationType modType, SchemaType type, object source) { List <AttributeChange> attributeChanges = this.GetLocalChanges(dn, modType, type, source); foreach (IApiInterface i in this.internalInterfaces) { attributeChanges.AddRange(i.GetChanges(dn, modType, type, source)); } return(attributeChanges); }
internal static GenericObjectWrapper Of(object nativeObject, SchemaType schemaType, byte[] schemaVersion) { return(new GenericObjectWrapper(nativeObject, schemaType, schemaVersion)); }
protected virtual DataTable FillSchema(DataTable dataTable, SchemaType schemaType, IDbCommand command, CommandBehavior behavior) { long logScopeId = DataCommonEventSource.Log.EnterScope("<comm.DbDataAdapter.FillSchema|API> {0}, dataTable, schemaType, command, behavior={1}", ObjectID, behavior); try { if (null == dataTable) { throw ADP.ArgumentNull(nameof(dataTable)); } if ((SchemaType.Source != schemaType) && (SchemaType.Mapped != schemaType)) { throw ADP.InvalidSchemaType(schemaType); } if (null == command) { throw ADP.MissingSelectCommand(ADP.FillSchema); } string srcTableName = dataTable.TableName; int index = IndexOfDataSetTable(srcTableName); if (-1 != index) { srcTableName = TableMappings[index].SourceTable; } return (DataTable)FillSchemaInternal(null, dataTable, schemaType, command, srcTableName, behavior | CommandBehavior.SingleResult); } finally { DataCommonEventSource.Log.ExitScope(logScopeId); } }
private GenericObjectWrapper(object nativeObject, SchemaType schemaType, byte[] schemaVersion) { _nativeObject = nativeObject; _schemaType = Precondition.Condition.RequireNonNull(schemaType, "SchemaType is required"); _schemaVersion = schemaVersion; }
public string ToJson(SchemaType schemaType) { return(ToJson(schemaType, Formatting.Indented)); }
/// <summary>Creates a Swagger specification from a JSON string.</summary> /// <param name="data">The JSON data.</param> /// <param name="documentPath">The document path (URL or file path) for resolving relative document references.</param> /// <param name="expectedSchemaType">The expected schema type which is used when the type cannot be determined.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>The <see cref="OpenApiDocument"/>.</returns> public static Task <OpenApiDocument> FromJsonAsync(string data, string documentPath, SchemaType expectedSchemaType, CancellationToken cancellationToken = default) { return(FromJsonAsync(data, documentPath, expectedSchemaType, null, cancellationToken)); }
// 获取数据库表信息,或者表结构信息,具体信息参照SchemaType查阅 /// <summary> /// 获取数据库表信息,或者表结构信息,具体信息参照SchemaType查阅 /// </summary> /// <param name="table">Tables,Columns,Primary_Keys</param> /// <param name="SchemaType"></param> /// <param name="v"></param> /// <returns></returns> public bool GetTableNames(ref DataTable table, SchemaType st = SchemaType.Tables, string tablename = "") { //•Databases //•ForeignKeys //•Indexes //•IndexColumns //•Procedures //•ProcedureParameters //•Tables //•Columns //•Users //•Views //•ViewColumns //•UserDefinedTypes //Oracle .net //•Columns //•Indexes //•IndexColumns //•Procedures //•Sequences //•Synonyms //•Tables //•Users //•Views //•Functions //•Packages //•PackageBodies //•Arguments //•UniqueKeys //•PrimaryKeys //•ForeignKeys //•ForeignKeyColumns //•ProcedureParameters try { string[] vstmp = new string[] { null, null, null, null }; table.Clear(); if (_Idbcon.State != ConnectionState.Open) { _Idbcon.Open(); } switch (st) { case SchemaType.Tables: table = _Idbcon.GetSchema("Tables"); break; case SchemaType.Columns: vstmp[2] = tablename; table = _Idbcon.GetSchema("Columns", vstmp); break; case SchemaType.Indexes: vstmp[2] = tablename; table = _Idbcon.GetSchema("Indexes", vstmp); break; case SchemaType.IndexColumns: vstmp[2] = tablename; table = _Idbcon.GetSchema("IndexColumns", vstmp); break; case SchemaType.Procedures: table = _Idbcon.GetSchema("Procedures"); break; default: return false; } return true; } catch (Exception ex) { RaiseEvent(new DataOperationErrorMessageArgs("获取表名信息错误", ex.Message)); return false; } }
/// <summary>Creates a Swagger specification from a JSON string.</summary> /// <param name="data">The JSON data.</param> /// <param name="documentPath">The document path (URL or file path) for resolving relative document references.</param> /// <param name="expectedSchemaType">The expected schema type which is used when the type cannot be determined.</param> /// <param name="referenceResolverFactory">The JSON reference resolver factory.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>The <see cref="OpenApiDocument"/>.</returns> public static async Task <OpenApiDocument> FromJsonAsync(string data, string documentPath, SchemaType expectedSchemaType, Func <OpenApiDocument, JsonReferenceResolver> referenceResolverFactory, CancellationToken cancellationToken = default) { // For explanation of the regex use https://regexr.com/ and the below unescaped pattern that is without named groups // (?:\"(openapi|swagger)\")(?:\s*:\s*)(?:\"([^"]*)\") var pattern = "(?:\\\"(?<schemaType>openapi|swagger)\\\")(?:\\s*:\\s*)(?:\\\"(?<schemaVersion>[^\"]*)\\\")"; var match = Regex.Match(data, pattern, RegexOptions.IgnoreCase); if (match.Success) { var schemaType = match.Groups["schemaType"].Value.ToLower(); var schemaVersion = match.Groups["schemaVersion"].Value.ToLower(); if (schemaType == "swagger" && schemaVersion.StartsWith("2")) { expectedSchemaType = SchemaType.Swagger2; } else if (schemaType == "openapi" && schemaVersion.StartsWith("3")) { expectedSchemaType = SchemaType.OpenApi3; } } if (expectedSchemaType == SchemaType.JsonSchema) { throw new NotSupportedException("The schema type JsonSchema is not supported."); } var contractResolver = GetJsonSerializerContractResolver(expectedSchemaType); return(await JsonSchemaSerialization.FromJsonAsync <OpenApiDocument>(data, expectedSchemaType, documentPath, document => { document.SchemaType = expectedSchemaType; if (referenceResolverFactory != null) { return referenceResolverFactory(document); } else { var schemaResolver = new OpenApiSchemaResolver(document, new JsonSchemaGeneratorSettings()); return new JsonReferenceResolver(schemaResolver); } }, contractResolver, cancellationToken).ConfigureAwait(false)); }
DataTable[] IDataAdapter.FillSchema(DataSet dataSet, SchemaType schemaType) { throw new NotSupportedException(); }
/// <summary> /// It is judged whether it is Master. /// </summary> /// <param name="schemaType"></param> /// <returns></returns> public static bool IsMaster(this SchemaType schemaType) { return(schemaType == SchemaType.Master); }
// this method builds the schema for a given datatable. it returns a int array with // "array[ordinal of datatable column] == index of source column in data reader". // each column in the datatable has a mapping to a specific column in the datareader, // the int array represents this match. internal int[] BuildSchema (IDataReader reader, DataTable table, SchemaType schemaType) { return BuildSchema (reader, table, schemaType, MissingSchemaAction, MissingMappingAction, TableMappings); }
/// <summary> /// It is judged whether it is User. /// </summary> /// <param name="schemaType"></param> /// <returns></returns> public static bool IsUser(this SchemaType schemaType) { return(schemaType == SchemaType.User); }
internal string SetupSchema (SchemaType schemaType, string sourceTableName) { DataTableMapping tableMapping = null; if (schemaType == SchemaType.Mapped) { tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction (TableMappings, sourceTableName, sourceTableName, MissingMappingAction); if (tableMapping != null) return tableMapping.DataSetTable; return null; } else return sourceTableName; }
/// <summary> /// It is judged whether it is Local. /// </summary> /// <param name="schemaType"></param> /// <returns></returns> public static bool IsLocal(this SchemaType schemaType) { return(schemaType == SchemaType.Local); }
protected virtual DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType, string srcTable, IDataReader dataReader) { throw new NotImplementedException (); }
public abstract DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType);
internal SchemeMap(NativeDataAdapter adapter, DataSet dataset, DataTable datatable, DataReaderContainer dataReader, bool keyInfo, SchemaType schemaType, string sourceTableName, bool gettingData, DataColumn parentChapterColumn, object parentChapterValue) { this._dataSet = dataset; this._dataTable = datatable; this._adapter = adapter; this._dataReader = dataReader; if (keyInfo) { this._schemaTable = dataReader.GetSchemaTable(); } MissingMappingAction missingMappingAction; MissingSchemaAction schemaAction; if (SchemaType.Mapped == schemaType) { missingMappingAction = this._adapter.MissingMappingAction; schemaAction = this._adapter.MissingSchemaAction; if (!string.IsNullOrEmpty(sourceTableName)) { this._tableMapping = this._adapter.GetTableMappingBySchemaAction(sourceTableName, sourceTableName, missingMappingAction); } else { if (this._dataTable != null) { int num = this._adapter.IndexOfDataSetTable(this._dataTable.TableName); if (-1 != num) { this._tableMapping = this._adapter.TableMappings[num]; } else { switch (missingMappingAction) { case MissingMappingAction.Passthrough: this._tableMapping = new DataTableMapping(this._dataTable.TableName, this._dataTable.TableName); break; case MissingMappingAction.Ignore: this._tableMapping = null; break; case MissingMappingAction.Error: throw new Exception("MissingTableMappingDestination"); default: throw new Exception("InvalidMissingMappingAction"); } } } } } else { if (SchemaType.Source != schemaType) { throw new Exception(); } missingMappingAction = MissingMappingAction.Passthrough; schemaAction = MissingSchemaAction.Add; if (!string.IsNullOrEmpty(sourceTableName)) { this._tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction(null, sourceTableName, sourceTableName, missingMappingAction); } else { if (this._dataTable != null) { int num2 = this._adapter.IndexOfDataSetTable(this._dataTable.TableName); if (-1 != num2) { this._tableMapping = this._adapter.TableMappings[num2]; } else { this._tableMapping = new DataTableMapping(this._dataTable.TableName, this._dataTable.TableName); } } } } if (this._tableMapping != null) { if (this._dataTable == null) { this._dataTable = this._tableMapping.GetDataTableBySchemaAction(this._dataSet, schemaAction); } if (this._dataTable != null) { this._fieldNames = SchemeMap.GenerateFieldNames(dataReader); if (this._schemaTable == null) { this._readerDataValues = this.SetupSchemaWithoutKeyInfo(missingMappingAction, schemaAction, gettingData, parentChapterColumn, parentChapterValue); return; } this._readerDataValues = this.SetupSchemaWithKeyInfo(missingMappingAction, schemaAction, gettingData, parentChapterColumn, parentChapterValue); } } }
internal SchemaMapping(DataAdapter adapter, DataSet dataset, System.Data.DataTable datatable, DataReaderContainer dataReader, bool keyInfo, SchemaType schemaType, string sourceTableName, bool gettingData, DataColumn parentChapterColumn, object parentChapterValue) { MissingMappingAction missingMappingAction; MissingSchemaAction missingSchemaAction; this._dataSet = dataset; this._dataTable = datatable; this._adapter = adapter; this._dataReader = dataReader; if (keyInfo) { this._schemaTable = dataReader.GetSchemaTable(); } if (adapter.ShouldSerializeFillLoadOption()) { this._loadOption = adapter.FillLoadOption; } else if (adapter.AcceptChangesDuringFill) { this._loadOption = (LoadOption) 4; } else { this._loadOption = (LoadOption) 5; } if (SchemaType.Mapped == schemaType) { missingMappingAction = this._adapter.MissingMappingAction; missingSchemaAction = this._adapter.MissingSchemaAction; if (ADP.IsEmpty(sourceTableName)) { if (this._dataTable != null) { int num2 = this._adapter.IndexOfDataSetTable(this._dataTable.TableName); if (-1 == num2) { switch (missingMappingAction) { case MissingMappingAction.Passthrough: this._tableMapping = new DataTableMapping(this._dataTable.TableName, this._dataTable.TableName); goto Label_01DB; case MissingMappingAction.Ignore: this._tableMapping = null; goto Label_01DB; case MissingMappingAction.Error: throw ADP.MissingTableMappingDestination(this._dataTable.TableName); } throw ADP.InvalidMissingMappingAction(missingMappingAction); } this._tableMapping = this._adapter.TableMappings[num2]; } } else { this._tableMapping = this._adapter.GetTableMappingBySchemaAction(sourceTableName, sourceTableName, missingMappingAction); } } else { if (SchemaType.Source != schemaType) { throw ADP.InvalidSchemaType(schemaType); } missingMappingAction = MissingMappingAction.Passthrough; missingSchemaAction = MissingSchemaAction.Add; if (!ADP.IsEmpty(sourceTableName)) { this._tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction(null, sourceTableName, sourceTableName, missingMappingAction); } else if (this._dataTable != null) { int num = this._adapter.IndexOfDataSetTable(this._dataTable.TableName); if (-1 != num) { this._tableMapping = this._adapter.TableMappings[num]; } else { this._tableMapping = new DataTableMapping(this._dataTable.TableName, this._dataTable.TableName); } } } Label_01DB: if (this._tableMapping != null) { if (this._dataTable == null) { this._dataTable = this._tableMapping.GetDataTableBySchemaAction(this._dataSet, missingSchemaAction); } if (this._dataTable != null) { this._fieldNames = GenerateFieldNames(dataReader); if (this._schemaTable == null) { this._readerDataValues = this.SetupSchemaWithoutKeyInfo(missingMappingAction, missingSchemaAction, gettingData, parentChapterColumn, parentChapterValue); return; } this._readerDataValues = this.SetupSchemaWithKeyInfo(missingMappingAction, missingSchemaAction, gettingData, parentChapterColumn, parentChapterValue); } } }
/// <summary>Creates the serializer contract resolver based on the <see cref="SchemaType"/>.</summary> /// <param name="schemaType">The schema type.</param> /// <returns>The settings.</returns> public static PropertyRenameAndIgnoreSerializerContractResolver CreateJsonSerializerContractResolver(SchemaType schemaType) { var resolver = JsonSchema4.CreateJsonSerializerContractResolver(schemaType); if (schemaType == SchemaType.OpenApi3) { resolver.IgnoreProperty(typeof(SwaggerDocument), "swagger"); resolver.IgnoreProperty(typeof(SwaggerDocument), "host"); resolver.IgnoreProperty(typeof(SwaggerDocument), "basePath"); resolver.IgnoreProperty(typeof(SwaggerDocument), "schemes"); //resolver.IgnoreProperty(typeof(SwaggerDocument), "consumes"); //resolver.IgnoreProperty(typeof(SwaggerDocument), "produces"); resolver.IgnoreProperty(typeof(SwaggerOperation), "schemes"); resolver.IgnoreProperty(typeof(SwaggerOperation), "consumes"); resolver.IgnoreProperty(typeof(SwaggerOperation), "produces"); //resolver.IgnoreProperty(typeof(SwaggerResponse), "consumes"); => TODO map to response.content //resolver.IgnoreProperty(typeof(SwaggerResponse), "produces"); resolver.IgnoreProperty(typeof(SwaggerDocument), "definitions"); resolver.IgnoreProperty(typeof(SwaggerDocument), "parameters"); resolver.IgnoreProperty(typeof(SwaggerDocument), "responses"); resolver.IgnoreProperty(typeof(SwaggerDocument), "securityDefinitions"); resolver.IgnoreProperty(typeof(SwaggerResponse), "schema"); resolver.IgnoreProperty(typeof(SwaggerResponse), "examples"); } else if (schemaType == SchemaType.Swagger2) { resolver.IgnoreProperty(typeof(SwaggerDocument), "openapi"); resolver.IgnoreProperty(typeof(SwaggerDocument), "servers"); resolver.IgnoreProperty(typeof(SwaggerParameter), "title"); // TODO: Use rename for not mapped properties! resolver.IgnoreProperty(typeof(SwaggerPathItem), "summary"); resolver.IgnoreProperty(typeof(SwaggerPathItem), "description"); resolver.IgnoreProperty(typeof(SwaggerPathItem), "servers"); resolver.IgnoreProperty(typeof(SwaggerOperation), "callbacks"); resolver.IgnoreProperty(typeof(SwaggerOperation), "servers"); resolver.IgnoreProperty(typeof(SwaggerDocument), "components"); resolver.IgnoreProperty(typeof(SwaggerParameter), "examples"); resolver.IgnoreProperty(typeof(SwaggerResponse), "content"); resolver.IgnoreProperty(typeof(SwaggerResponse), "links"); } return(resolver); }
/// <summary> /// It is judged whether it is Enumeration. /// </summary> /// <param name="schemaType"></param> /// <returns></returns> public static bool IsEnumeration(this SchemaType schemaType) { return(schemaType == SchemaType.Enumeration); }
public IList <AttributeChange> ApplyChanges(CSEntryChange csentry, SchemaType type, ref object target, bool patch = false) { bool hasChanged = false; List <AttributeChange> changes = new List <AttributeChange>(); if (!(target is GoogleGroup group)) { throw new InvalidOperationException(); } if (this.SetDNValue(csentry, group)) { hasChanged = true; } foreach (IAttributeAdapter typeDef in this.SchemaType.AttributeAdapters.Where(t => t.Api == this.Api)) { if (typeDef.UpdateField(csentry, group.Group)) { hasChanged = true; } } if (hasChanged) { GoogleGroup result = new GoogleGroup(); if (csentry.ObjectModificationType == ObjectModificationType.Add) { result.Group = this.config.GroupsService.Add(group.Group); group.Group = result.Group; // Group membership operations fail on newly created groups if processed too quickly System.Threading.Thread.Sleep(1000); } else if (csentry.ObjectModificationType == ObjectModificationType.Replace || csentry.ObjectModificationType == ObjectModificationType.Update) { string id = csentry.GetAnchorValueOrDefault <string>("id"); if (patch) { result.Group = this.config.GroupsService.Patch(id, group.Group); group.Group = result.Group; } else { result.Group = this.config.GroupsService.Update(id, group.Group); group.Group = result.Group; } } else { throw new InvalidOperationException(); } changes.AddRange(this.GetLocalChanges(csentry.DN, csentry.ObjectModificationType, type, result)); } foreach (IApiInterface i in this.internalInterfaces) { foreach (AttributeChange c in i.ApplyChanges(csentry, type, ref target, patch)) { //changes.RemoveAll(t => t.Name == c.Name); changes.Add(c); } } return(changes); }
internal SchemaMapping(DataAdapter adapter, DataSet dataset, DataTable datatable, DataReaderContainer dataReader, bool keyInfo, SchemaType schemaType, string sourceTableName, bool gettingData, DataColumn parentChapterColumn, object parentChapterValue) { Debug.Assert(null != adapter, "adapter"); Debug.Assert(null != dataReader, "dataReader"); Debug.Assert(0 < dataReader.FieldCount, "FieldCount"); Debug.Assert(null != dataset || null != datatable, "SchemaMapping - null dataSet"); Debug.Assert(SchemaType.Mapped == schemaType || SchemaType.Source == schemaType, "SetupSchema - invalid schemaType"); _dataSet = dataset; // setting DataSet implies chapters are supported _dataTable = datatable; // setting only DataTable, not DataSet implies chapters are not supported _adapter = adapter; _dataReader = dataReader; if (keyInfo) { _schemaTable = dataReader.GetSchemaTable(); } if (adapter.ShouldSerializeFillLoadOption()) { _loadOption = adapter.FillLoadOption; } else if (adapter.AcceptChangesDuringFill) { _loadOption = (LoadOption)4; // true } else { _loadOption = (LoadOption)5; //false } MissingMappingAction mappingAction; MissingSchemaAction schemaAction; if (SchemaType.Mapped == schemaType) { mappingAction = _adapter.MissingMappingAction; schemaAction = _adapter.MissingSchemaAction; if (!ADP.IsEmpty(sourceTableName)) { // MDAC 66034 _tableMapping = _adapter.GetTableMappingBySchemaAction(sourceTableName, sourceTableName, mappingAction); } else if (null != _dataTable) { int index = _adapter.IndexOfDataSetTable(_dataTable.TableName); if (-1 != index) { _tableMapping = _adapter.TableMappings[index]; } else { switch (mappingAction) { case MissingMappingAction.Passthrough: _tableMapping = new DataTableMapping(_dataTable.TableName, _dataTable.TableName); break; case MissingMappingAction.Ignore: _tableMapping = null; break; case MissingMappingAction.Error: throw ADP.MissingTableMappingDestination(_dataTable.TableName); default: throw ADP.InvalidMissingMappingAction(mappingAction); } } } } else if (SchemaType.Source == schemaType) { mappingAction = System.Data.MissingMappingAction.Passthrough; schemaAction = Data.MissingSchemaAction.Add; if (!ADP.IsEmpty(sourceTableName)) { // MDAC 66034 _tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction(null, sourceTableName, sourceTableName, mappingAction); } else if (null != _dataTable) { int index = _adapter.IndexOfDataSetTable(_dataTable.TableName); // MDAC 66034 if (-1 != index) { _tableMapping = _adapter.TableMappings[index]; } else { _tableMapping = new DataTableMapping(_dataTable.TableName, _dataTable.TableName); } } } else { throw ADP.InvalidSchemaType(schemaType); } if (null != _tableMapping) { if (null == _dataTable) { _dataTable = _tableMapping.GetDataTableBySchemaAction(_dataSet, schemaAction); } if (null != _dataTable) { _fieldNames = GenerateFieldNames(dataReader); if (null == _schemaTable) { _readerDataValues = SetupSchemaWithoutKeyInfo(mappingAction, schemaAction, gettingData, parentChapterColumn, parentChapterValue); } else { _readerDataValues = SetupSchemaWithKeyInfo(mappingAction, schemaAction, gettingData, parentChapterColumn, parentChapterValue); } } // else (null == _dataTable) which means ignore (mapped to nothing) } }
public new void FillSchema(DataTable dataTable, SchemaType schemaType, IDataReader dataReader) { base.FillSchema(dataTable, schemaType, dataReader); }
/// <summary> /// It is judged whether it is None. /// </summary> /// <param name="schemaType"></param> /// <returns></returns> public static bool IsNone(this SchemaType schemaType) { return(schemaType == SchemaType.None); }
protected UnnamedSchema(SchemaType type, PropertyMap props) : base(type, props) { }