internal static void RaiseEvent(EventHandler<ReaderEventArgs> eventHandler, object sender, ProgressType progressType, SchemaObjectType schemaObjectType) { RaiseEvent(eventHandler, sender, progressType, schemaObjectType, null, null, null); }
public static string GetStringFromSchemaObjectType(SchemaObjectType type) { if (type == SchemaObjectType.ObjectTypeDimension) { return("Dimension"); } else if (type == SchemaObjectType.ObjectTypeHierarchy) { return("Hierarchy"); } else if (type == SchemaObjectType.ObjectTypeLevel) { return("Level"); } else if (type == SchemaObjectType.ObjectTypeMeasure) { return("Measure"); } else if (type == SchemaObjectType.ObjectTypeMember) { return("Member"); } throw new Exception("Invalid type: " + type.ToString()); }
/// <summary> /// Parse the SQL to determine the type and name /// </summary> private string ParseSql() { // find the first match by position, then by type var match = SqlParser.Parsers.Select(p => p.Match(_sql)) .Where(m => m != null) .OrderBy(m => m.Position) .ThenBy(m => m.SchemaObjectType) .FirstOrDefault(); // if we didn't get a match, then throw an exception if (match == null) { throw new SchemaParsingException(Properties.Resources.CannotDetermineScriptType, _sql); } // if the sql contains something that we know that we don't support, then throw an exception var invalid = SqlParser.UnsupportedSql.Select(p => p.Match(_sql)).Where(m => m != null).FirstOrDefault(); if (invalid != null) { throw new SchemaParsingException(String.Format(CultureInfo.InvariantCulture, "Error parsing Sql: {0}", invalid.Name), _sql); } // fill in the type and name _type = match.SchemaObjectType; return(match.Name); }
internal static void RaiseEvent(EventHandler <ReaderEventArgs> eventHandler, object sender, ProgressType progressType, SchemaObjectType schemaObjectType) { RaiseEvent(eventHandler, sender, progressType, schemaObjectType, null, null, null); }
protected void RaiseProgress(ProgressType progressType, SchemaObjectType schemaObjectType, string name, int?index, int?count) { ReaderEventArgs.RaiseEvent(ReaderProgress, this, progressType, schemaObjectType, name, index, count); }
private static IList <string> GetFileNames(SchemaObjectType type, DatabaseSchemaSettings settings) { var location = string.Empty; switch (type) { case SchemaObjectType.UserDefinedType: location = settings.FileLocations.UserDefinedTypesLocation; break; case SchemaObjectType.UserDefinedTableType: location = settings.FileLocations.UserDefinedTableTypesLocation; break; case SchemaObjectType.Table: location = settings.FileLocations.TablesLocation; break; case SchemaObjectType.View: location = settings.FileLocations.ViewsLocation; break; case SchemaObjectType.StoredProcedure: location = settings.FileLocations.StoredProceduresLocation; break; case SchemaObjectType.Function: location = settings.FileLocations.FunctionsLocation; break; default: throw new ArgumentException($"{type} SchemaType is not supported."); } return(GetFileNames(location)); }
/// <summary> /// Create a parser that detects a type from a pattern /// </summary> /// <param name="type">The type represented by the pattern</param> /// <param name="pattern">The pattern to detect</param> /// <param name="nameTemplate">The string used to generate the resulting name</param> public SqlParser(SchemaObjectType type, string pattern, string nameTemplate = "$1") { // NOTE: don't use compiled regex here. the expressions are too complicated for the 64-bit JIT and it takes 10x more time. really. SchemaObjectType = type; _regex = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture); _nameTemplate = nameTemplate; }
/// <summary> /// Constructs a SchemaObject of the given type, name, and sql script /// </summary> /// <param name="type">The type of the SchemaObject</param> /// <param name="name">The name of the SchemaObject</param> /// <param name="sql">The SQL script for the SchemaObject</param> /// <remarks>The type and name must match the SQL script.</remarks> /// <exception cref="ArgumentNullException">If name or sql is null</exception> internal SchemaObject (SchemaObjectType type, string name, string sql) { if (name == null) throw new ArgumentNullException ("name"); _type = type; _sql = sql; _implementation = SchemaImpl.GetImplementation(_type, name, _sql); }
private ReaderEventArgs(ProgressType progressType, SchemaObjectType schemaObjectType, string name, int? index, int? count) { ProgressType = progressType; SchemaObjectType = schemaObjectType; Name = name; Index = index; Count = count; }
private ReaderEventArgs(ProgressType progressType, SchemaObjectType schemaObjectType, string name, int?index, int?count) { ProgressType = progressType; SchemaObjectType = schemaObjectType; Name = name; Index = index; Count = count; }
private string LookupStoreSalesforce(SchemaObjectType type, string uniqueName) { if (_destCube == null) { throw new Exception("Destination cube not accessible"); } // if from group level, which does not exist if (type == SchemaObjectType.ObjectTypeMember && uniqueName.StartsWith("[Store].[Salesforce].[Group].&[") && uniqueName.IndexOf(".&[") == uniqueName.LastIndexOf(".&[")) { return("[Salesforce Stores].[Salesforce Stores].[All]"); } // create index if not exists if (_storeSalesforceIndex == null) { _storeSalesforceIndex = new Hashtable(); Hierarchy hier = _destCube.Dimensions["Salesforce Stores"].Hierarchies[0]; foreach (Member m in hier.Levels["Salesforce"].GetMembers()) { if (m.Name != "Undefined") // undefined handeled separately { int delim = m.UniqueName.LastIndexOf(".&["); string key = m.UniqueName.Substring(delim + 3, m.UniqueName.Length - delim - 4).ToUpper(); _storeSalesforceIndex.Add(key, m.UniqueName); } } foreach (Member m in hier.Levels["Store"].GetMembers()) { int delim = m.UniqueName.LastIndexOf("&["); string key = m.UniqueName.Substring(delim + 2, m.UniqueName.Length - delim - 3).ToUpper(); if (!_storeSalesforceIndex.ContainsKey(key)) { _storeSalesforceIndex.Add(key, m.UniqueName); } } // undefined _storeSalesforceIndex.Add("0", "[Salesforce Stores].[Salesforce Stores].[All].UNKNOWNMEMBER"); _storeSalesforceIndex.Add("Undefined", "[Salesforce Stores].[Salesforce Stores].[All].UNKNOWNMEMBER"); } // get name and lookup from index string ret = null; int delimiter = uniqueName.LastIndexOf(".&["); if (delimiter >= 0) { string name = uniqueName.Substring(delimiter + 3, uniqueName.Length - delimiter - 4).ToUpper(); ret = _storeSalesforceIndex[name] as string; } return(ret); }
public string ConvertSchemaObjectUN(SchemaObjectType type, string uniqueName) { SourceSchemaMap.MapRow row = null; string toReplace = uniqueName; // if its' member, extract parent object if (type == SchemaObjectType.ObjectTypeMember) { // lookup by key int delimiterIndex = uniqueName.IndexOf("].&["); if (delimiterIndex >= 0) { toReplace = uniqueName.Substring(0, delimiterIndex + 1); // try to lookup as level row = this.GetMapRow(SchemaObjectType.ObjectTypeLevel, toReplace); // if not found, try as hierarchy if (row == null) { row = this.GetMapRow(SchemaObjectType.ObjectTypeHierarchy, toReplace); } } else { // if measure if (uniqueName.StartsWith("[Measures]")) { row = this.GetMapRow(SchemaObjectType.ObjectTypeMeasure, toReplace); } else // lookup as member (all member) { row = this.GetMapRow(SchemaObjectType.ObjectTypeMember, toReplace); } //if (row == null) // throw new Exception("Unable to find parent object for member " + uniqueName); } } else // straight full-name lookup { row = this.GetMapRow(type, toReplace); } // return if (row == null || row.IsDestUniqueNameNull() || row.DestUniqueName == "") { return(null); } else { string replaceWith = row.DestUniqueName.Substring(row.DestUniqueName.IndexOf(':', 0) + 1); return(uniqueName.Replace(toReplace, replaceWith)); } }
/// <summary> /// Constructs a SchemaObject of the given type, name, and sql script /// </summary> /// <param name="type">The type of the SchemaObject</param> /// <param name="name">The name of the SchemaObject</param> /// <param name="sql">The SQL script for the SchemaObject</param> /// <remarks>The type and name must match the SQL script.</remarks> /// <exception cref="ArgumentNullException">If name or sql is null</exception> internal SchemaObject(SchemaObjectType type, string name, string sql) { if (name == null) { throw new ArgumentNullException("name"); } _type = type; _sql = sql; _implementation = SchemaImpl.GetImplementation(_type, name, _sql); }
internal static void RaiseEvent(EventHandler<ReaderEventArgs> eventHandler, object sender, ProgressType progressType, SchemaObjectType schemaObjectType, string name, int? index, int? count) { var handler = eventHandler; if (handler != null) { handler(sender, new ReaderEventArgs(progressType, schemaObjectType, name, index, count)); } }
internal static void RaiseEvent(EventHandler <ReaderEventArgs> eventHandler, object sender, ProgressType progressType, SchemaObjectType schemaObjectType, string name, int?index, int?count) { var handler = eventHandler; if (handler != null) { handler(sender, new ReaderEventArgs(progressType, schemaObjectType, name, index, count)); } }
DataRow IMetadataCache.FindObjectByUniqueName(SchemaObjectType objectType, string nameUnique) { this.Populate((InternalObjectType)objectType); ObjectMetadataCache objectCache = this.GetObjectCache((InternalObjectType)objectType); string dataTableFilter = AdomdUtils.GetDataTableFilter(this.GetUniqueNameColumn((InternalObjectType)objectType), nameUnique); DataRow[] filteredRows = ((IObjectCache)objectCache).GetFilteredRows(null, dataTableFilter); if (filteredRows.Length <= 0) { return(null); } return(filteredRows[0]); }
public object GetSchemaObject(SchemaObjectType schemaObjectType, string uniqueName, bool retryUniqueNameOnServer) { if (uniqueName == null) { throw new ArgumentNullException("uniqueName"); } if (uniqueName.Length == 0) { throw new ArgumentException(SR.ArgumentErrorUniqueNameEmpty, "uniqueName"); } if (!SchemaObjectTypeChecker.IsValidSchemaObjectType(schemaObjectType)) { throw new ArgumentException(SR.ArgumentErrorInvalidSchemaObjectType, "schemaObjectType"); } return(this.InternalGetSchemaObject(schemaObjectType, uniqueName, retryUniqueNameOnServer)); }
private void Create(SchemaObjectType type, DatabaseSchemaSettings settings) { _logger.Log(LogLevel.Information, $"Generate schema ... creating {type.ToString().ToLower()}s"); _logger.Log(string.Empty); var fileNames = GetFileNames(type, settings); // TODO : as parallel (use concurrent dictionary for schema?) // same as below, what about missing references? foreach (var fileName in fileNames) { _logger.Log(LogLevel.Information, $"Creating schema from {fileName}"); using (var reader = new StreamReader(fileName)) { var fileContent = reader.ReadToEnd(); var parserOutput = _parser.ParseString(fileContent); if (parserOutput.ParsingErrors != null && parserOutput.ParsingErrors.Count > 0) { _logger.LogParsingErrors(parserOutput, fileName); continue; // just move on } // TODO : How to order views and SPs to avoid missing schema references? // how many times would we need to rerun the process? // identify dependencies? var newDatabaseObjects = _statements .Where(statement => statement.Type.Equals(type)) .SelectMany(statement => CreateFromStatement(statement, settings, fileName, fileContent, parserOutput)) .ToList(); // eval } } if (fileNames.Any()) { _logger.Log(string.Empty); } }
private string LookupMSAAttributes(SchemaObjectType type, string uniqueName) { if (_destCube == null) { throw new Exception("Destination cube not accessible"); } if (type != SchemaObjectType.ObjectTypeMember) { return(null); } // if member is from last level Member mem = (Member)_srcCube.GetSchemaObject(type, uniqueName); if (mem == null || mem.LevelDepth < 2) { return(null); } // get siblings and find position MemberCollection siblings = mem.Parent.GetChildren(); int index = 0; for (int i = 0; i < siblings.Count; i++) { if (siblings[i].UniqueName == mem.UniqueName) { index = i; break; } } // get parent from destination and find child by position string destParentUn = _map.ConvertSchemaObjectUN(SchemaObjectType.ObjectTypeMember, mem.Parent.UniqueName); Member destParent = (Member)_destCube.GetSchemaObject(SchemaObjectType.ObjectTypeMember, destParentUn); Member ret = destParent.GetChildren()[index]; return(ret.UniqueName); }
private object GetSchemaObject(CubeDef cube, SchemaObjectType type, string uniqueName, bool throwNotFound) { try { return(cube == null ? null : cube.GetSchemaObject(type, uniqueName, true)); } catch (Exception exc) { // object not found from 9.0 and 8.0 analysis services connections if (exc.Message.Contains("object was not found") || exc.Message.StartsWith("Invalid syntax for schema")) { if (throwNotFound) { throw new Exception(string.Format("Member '{0}' not found in cube '{1}'", uniqueName, cube.Name)); } return(null); } throw exc; // other exception } }
public static object LookupAdomdSchemaObject(CubeDef cube, SchemaObjectType type, string uniqueName) { try { return(cube.GetSchemaObject(type, uniqueName, true)); } catch (Exception exc) { // object not found from old analysis services connection if (exc.Message.Contains("Invalid syntax for schema")) { return(null); } // object not found from new analysis services connection if (exc.Message.Contains("object was not found")) { return(null); } throw exc; } }
public SchemaObject( int id, string schema, string name, SchemaObjectType type, DateTime createDate, DateTime modifyDate, ColumnSubObject[] columns, ParameterSubObject[] parameters ) { Id = id; Schema = schema ?? ""; Name = name ?? ""; FullName = Schema + "." + Name; Type = type; CreateDate = createDate; ModifyDate = modifyDate; Columns = columns ?? new ColumnSubObject[0]; Parameters = parameters ?? new ParameterSubObject[0]; m_asString = "SO." + FullName; }
/// <summary> /// Drop an object from the database /// </summary> /// <param name="connection">The Sql connection to use</param> /// <param name="type">The type of the object</param> /// <param name="objectName">The name of the object</param> internal static void Drop(IDbConnection connection, SchemaObjectType type, string objectName) { var implementation = SchemaImpl.GetImplementation(type, objectName, null); implementation.Drop(connection); }
/// <summary> /// Parse the SQL to determine the type and name /// </summary> private string ParseSql () { // find the first match by position, then by type var match = SqlParser.Parsers.Select(p => p.Match(_sql)) .Where(m => m != null) .OrderBy(m => m.Position) .ThenBy(m => m.SchemaObjectType) .FirstOrDefault(); // if we didn't get a match, then throw an exception if (match == null) throw new SchemaParsingException (Properties.Resources.CannotDetermineScriptType, _sql); // if the sql contains something that we know that we don't support, then throw an exception var invalid = SqlParser.UnsupportedSql.Select(p => p.Match(_sql)).Where(m => m != null).FirstOrDefault(); if (invalid != null) throw new SchemaParsingException(String.Format(CultureInfo.InvariantCulture, "Error parsing Sql: {0}", invalid.Name), _sql); // fill in the type and name _type = match.SchemaObjectType; return match.Name; }
public SourceSchemaMap.MapRow GetMapRow(SchemaObjectType type, string uniqueName) { return(GetMapRow(GetStringFromSchemaObjectType(type), uniqueName)); }
public static object LookupAdomdSchemaObject(CubeDef cube, string objectType, string uniqueName) { SchemaObjectType type = GetSchemaObjectTypeFromString(objectType); return(LookupAdomdSchemaObject(cube, type, uniqueName)); }
public static SchemaImpl GetImplementation(SchemaObjectType type, string name, string sql) { switch (type) { case SchemaObjectType.AutoProc: return new AutoProc(name, sql); case SchemaObjectType.BrokerPriority: return new BrokerPriority(name, sql); case SchemaObjectType.Certificate: return new Certificate(name, sql); case SchemaObjectType.Contract: return new Contract(name, sql); case SchemaObjectType.Constraint: return new Constraint(name, sql); case SchemaObjectType.Default: return new Default(name, sql); case SchemaObjectType.Index: return new Index(name, sql); case SchemaObjectType.ForeignKey: return new Constraint(name, sql); case SchemaObjectType.Function: return new Function(name, sql); case SchemaObjectType.IndexedView: return new View(name, sql); case SchemaObjectType.Login: return new Login(name, sql); case SchemaObjectType.MasterKey: return new MasterKey(name, sql); case SchemaObjectType.MessageType: return new MessageType(name, sql); case SchemaObjectType.PartitionFunction: return new PartitionFunction(name, sql); case SchemaObjectType.PartitionScheme: return new PartitionScheme(name, sql); case SchemaObjectType.Permission: return new Permission(name, sql); case SchemaObjectType.PrimaryKey: return new PrimaryKey(name, sql); case SchemaObjectType.PrimaryXmlIndex: return new Index(name, sql); case SchemaObjectType.Queue: return new Queue(name, sql); case SchemaObjectType.Role: return new Role(name, sql); case SchemaObjectType.Schema: return new Schema(name, sql); case SchemaObjectType.SecondaryXmlIndex: return new Index(name, sql); case SchemaObjectType.Service: return new Service(name, sql); case SchemaObjectType.StoredProcedure: return new StoredProcedure(name, sql); case SchemaObjectType.Table: return new Table(name, sql); case SchemaObjectType.Trigger: return new Trigger(name, sql); case SchemaObjectType.User: return new User(name, sql); case SchemaObjectType.UserDefinedType: return new UserDefinedType(name, sql); case SchemaObjectType.View: return new View(name, sql); case SchemaObjectType.UserPreScript: case SchemaObjectType.Unused: case SchemaObjectType.Script: case SchemaObjectType.UserScript: return new Script(name, sql); default: return null; } }
public object GetSchemaObject(SchemaObjectType schemaObjectType, string uniqueName) { return(this.GetSchemaObject(schemaObjectType, uniqueName, true)); }
internal static bool IsValidSchemaObjectType(SchemaObjectType type) { return((type >= SchemaObjectType.ObjectTypeDimension && type <= SchemaObjectType.ObjectTypeMiningServiceParameter) || type == SchemaObjectType.ObjectTypeNamedSet); }
protected void RaiseReadingProgress(SchemaObjectType schemaObjectType) { ReaderEventArgs.RaiseEvent(ReaderProgress, this, ProgressType.ReadingSchema, schemaObjectType); }
private static bool CanRebuild(SchemaObjectType schemaObjectType) { if (CanRebuildSafely (schemaObjectType)) return true; switch (schemaObjectType) { case SchemaObjectType.IndexedView: case SchemaObjectType.Index: case SchemaObjectType.PrimaryKey: case SchemaObjectType.PrimaryXmlIndex: case SchemaObjectType.SecondaryXmlIndex: case SchemaObjectType.UserScript: return true; } return false; }
public static SchemaImpl GetImplementation(SchemaObjectType type, string name, string sql) { switch (type) { case SchemaObjectType.AutoProc: return(new AutoProc(name, sql)); case SchemaObjectType.BrokerPriority: return(new BrokerPriority(name, sql)); case SchemaObjectType.Certificate: return(new Certificate(name, sql)); case SchemaObjectType.Contract: return(new Contract(name, sql)); case SchemaObjectType.Constraint: return(new Constraint(name, sql)); case SchemaObjectType.Default: return(new Default(name, sql)); case SchemaObjectType.Index: return(new Index(name, sql)); case SchemaObjectType.ForeignKey: return(new Constraint(name, sql)); case SchemaObjectType.Function: return(new Function(name, sql)); case SchemaObjectType.IndexedView: return(new View(name, sql)); case SchemaObjectType.Login: return(new Login(name, sql)); case SchemaObjectType.MasterKey: return(new MasterKey(name, sql)); case SchemaObjectType.MessageType: return(new MessageType(name, sql)); case SchemaObjectType.PartitionFunction: return(new PartitionFunction(name, sql)); case SchemaObjectType.PartitionScheme: return(new PartitionScheme(name, sql)); case SchemaObjectType.Permission: return(new Permission(name, sql)); case SchemaObjectType.PrimaryKey: return(new PrimaryKey(name, sql)); case SchemaObjectType.PrimaryXmlIndex: return(new Index(name, sql)); case SchemaObjectType.Queue: return(new Queue(name, sql)); case SchemaObjectType.Role: return(new Role(name, sql)); case SchemaObjectType.Schema: return(new Schema(name, sql)); case SchemaObjectType.SecondaryXmlIndex: return(new Index(name, sql)); case SchemaObjectType.Service: return(new Service(name, sql)); case SchemaObjectType.StoredProcedure: return(new StoredProcedure(name, sql)); case SchemaObjectType.SymmetricKey: return(new SymmetricKey(name, sql)); case SchemaObjectType.Table: return(new Table(name, sql)); case SchemaObjectType.Trigger: return(new Trigger(name, sql)); case SchemaObjectType.User: return(new User(name, sql)); case SchemaObjectType.UserDefinedType: return(new UserDefinedType(name, sql)); case SchemaObjectType.View: return(new View(name, sql)); case SchemaObjectType.UserPreScript: case SchemaObjectType.InternalPreScript: case SchemaObjectType.Unused: case SchemaObjectType.Script: case SchemaObjectType.UserScript: return(new Script(name, sql)); default: return(null); } }
public static Guid GetSchemaGuid(LdapConnection conn, string schemaNcDn, string objectName, SchemaObjectType objectType) { if (conn == null || schemaNcDn == null || objectName == null) { throw new ArgumentNullException("Method does not accept null parameters"); } SearchRequest rq = new SearchRequest(); switch (objectType) { case SchemaObjectType.Attribute: rq.Filter = string.Format(System.Globalization.CultureInfo.InvariantCulture, "(&(objectClass=attributeSchema)(cn={0}))", objectName); break; case SchemaObjectType.Class: rq.Filter = string.Format(System.Globalization.CultureInfo.InvariantCulture, "(&(objectClass=classSchema)(cn={0}))", objectName); break; default: rq.Filter = string.Format(System.Globalization.CultureInfo.InvariantCulture, "(cn={0})", objectName); break; } rq.DistinguishedName = schemaNcDn; rq.Attributes.Add("schemaIDGuid"); SearchResponse rsp = (SearchResponse)conn.SendRequest(rq); if (rsp.Entries.Count == 0) { throw new DirectoryOperationException("No such object found"); } byte[] rawGuid = rsp.Entries[0].Attributes["schemaidguid"].GetValues(typeof(byte[]))[0] as byte[]; return(new Guid(rawGuid)); }
private void RaiseReadingProgress(SchemaObjectType schemaObjectType) { ReaderEventArgs.RaiseEvent(ReaderProgress, this, ProgressType.ReadingSchema, schemaObjectType, null, null, null); }
internal object InternalGetSchemaObject(SchemaObjectType schemaObjectType, string uniqueName, bool retryUniqueName) { DataRow dataRow; if (SchemaObjectType.ObjectTypeMember == schemaObjectType) { ListDictionary listDictionary = new ListDictionary(); listDictionary.Add(CubeCollectionInternal.cubeNameRest, this.Name); AdomdUtils.AddCubeSourceRestrictionIfApplicable(this.Connection, listDictionary); string requestType = "MDSCHEMA_MEMBERS"; string key = "MEMBER_UNIQUE_NAME"; listDictionary.Add(key, uniqueName); AdomdUtils.AddMemberBinaryRestrictionIfApplicable(this.Connection, listDictionary); DataRowCollection rows = AdomdUtils.GetRows(this.Connection, requestType, listDictionary); if (rows.Count != 1) { throw new ArgumentException(SR.Indexer_ObjectNotFound(uniqueName), "uniqueName"); } dataRow = rows[0]; } else { dataRow = this.metadataCache.FindObjectByUniqueName(schemaObjectType, uniqueName); if (dataRow == null && retryUniqueName) { ListDictionary listDictionary2 = new ListDictionary(); listDictionary2.Add(CubeCollectionInternal.cubeNameRest, this.Name); AdomdUtils.AddCubeSourceRestrictionIfApplicable(this.Connection, listDictionary2); string schemaName; string text; switch (schemaObjectType) { case SchemaObjectType.ObjectTypeDimension: schemaName = DimensionCollectionInternal.schemaName; text = DimensionCollectionInternal.dimUNameRest; goto IL_16D; case SchemaObjectType.ObjectTypeHierarchy: schemaName = HierarchyCollectionInternal.schemaName; text = HierarchyCollectionInternal.hierUNameRest; goto IL_16D; case SchemaObjectType.ObjectTypeLevel: schemaName = LevelCollectionInternal.schemaName; text = LevelCollectionInternal.levelUNameRest; goto IL_16D; case SchemaObjectType.ObjectTypeMember: case (SchemaObjectType)5: break; case SchemaObjectType.ObjectTypeMeasure: schemaName = MeasureCollectionInternal.schemaName; text = Measure.uniqueNameColumn; goto IL_16D; case SchemaObjectType.ObjectTypeKpi: schemaName = KpiCollectionInternal.schemaName; text = Kpi.kpiNameColumn; goto IL_16D; default: if (schemaObjectType == SchemaObjectType.ObjectTypeNamedSet) { schemaName = NamedSetCollectionInternal.schemaName; text = "SET_NAME"; goto IL_16D; } break; } throw new ArgumentOutOfRangeException("schemaObjectType"); IL_16D: listDictionary2.Add(text, uniqueName); AdomdUtils.AddObjectVisibilityRestrictionIfApplicable(this.Connection, schemaName, listDictionary2); DataRowCollection rows2 = AdomdUtils.GetRows(this.Connection, schemaName, listDictionary2); if (rows2.Count > 0) { uniqueName = (rows2[0][text] as string); if (uniqueName != null) { dataRow = this.metadataCache.FindObjectByUniqueName(schemaObjectType, uniqueName); } } } } if (dataRow == null) { throw new ArgumentException(SR.Indexer_ObjectNotFound(uniqueName), "uniqueName"); } switch (schemaObjectType) { case SchemaObjectType.ObjectTypeDimension: { object result = DimensionCollectionInternal.GetDimensionByRow(this.Connection, dataRow, this, this.baseData.Catalog, this.baseData.SessionID); return(result); } case SchemaObjectType.ObjectTypeHierarchy: { Dimension parentDimension = (Dimension)this.InternalGetSchemaObject(SchemaObjectType.ObjectTypeDimension, dataRow[Dimension.uniqueNameColumn].ToString()); object result = HierarchyCollectionInternal.GetHiearchyByRow(this.Connection, dataRow, parentDimension, this.baseData.Catalog, this.baseData.SessionID); return(result); } case SchemaObjectType.ObjectTypeLevel: { string uniqueName2 = dataRow[Hierarchy.uniqueNameColumn].ToString(); Hierarchy parentHierarchy = (Hierarchy)this.InternalGetSchemaObject(SchemaObjectType.ObjectTypeHierarchy, uniqueName2); object result = LevelCollectionInternal.GetLevelByRow(this.Connection, dataRow, parentHierarchy, this.baseData.Catalog, this.baseData.SessionID); return(result); } case SchemaObjectType.ObjectTypeMember: { object result = new Member(this.Connection, dataRow, null, null, MemberOrigin.Metadata, this.Name, null, -1, this.baseData.Catalog, this.baseData.SessionID); return(result); } case (SchemaObjectType)5: break; case SchemaObjectType.ObjectTypeMeasure: { object result = MeasureCollectionInternal.GetMeasureByRow(this.Connection, dataRow, this, this.baseData.Catalog, this.baseData.SessionID); return(result); } case SchemaObjectType.ObjectTypeKpi: { object result = KpiCollectionInternal.GetKpiByRow(this.Connection, dataRow, this, this.baseData.Catalog, this.baseData.SessionID); return(result); } default: if (schemaObjectType == SchemaObjectType.ObjectTypeNamedSet) { object result = NamedSetCollectionInternal.GetNamedSetByRow(this.Connection, dataRow, this, this.baseData.Catalog, this.baseData.SessionID); return(result); } break; } throw new ArgumentOutOfRangeException("schemaObjectType"); }
internal object InternalGetSchemaObject(SchemaObjectType schemaObjectType, string uniqueName) { return(this.InternalGetSchemaObject(schemaObjectType, uniqueName, false)); }
private static bool CanRebuildSafely(SchemaObjectType schemaObjectType) { if (IsEasyToModify (schemaObjectType)) return true; switch (schemaObjectType) { case SchemaObjectType.Constraint: case SchemaObjectType.ForeignKey: return true; } return false; }
protected void RaiseProgress(ProgressType progressType, SchemaObjectType schemaObjectType, string name, int? index, int? count) { ReaderEventArgs.RaiseEvent(ReaderProgress, this, progressType, schemaObjectType, name, index, count); }
private static bool IsEasyToModify (SchemaObjectType schemaObjectType) { switch (schemaObjectType) { case SchemaObjectType.View: case SchemaObjectType.Function: case SchemaObjectType.StoredProcedure: case SchemaObjectType.Permission: case SchemaObjectType.Trigger: return true; } return false; }
private string ValidateOlapObject(SchemaObjectType type, string uniqueName, ReportsValidation.OlapReportsRow row) { // resolve source object object srcObject = (_srcUnmatched.Contains(uniqueName) ? null : SourceSchemaMap.LookupAdomdSchemaObject(_srcCube, type, uniqueName)); if (srcObject == null) { if (!_srcUnmatched.Contains(uniqueName)) { _srcUnmatched.Add(uniqueName); } row.ObjectsInvalid++; } // try to convert manually string destUniqueName = null; if (!_destUnmatched.Contains(uniqueName)) { if (uniqueName.StartsWith("[Central Chain]")) { destUniqueName = LookupCentralChain(uniqueName); } else if (uniqueName.StartsWith("[Chain]")) { destUniqueName = LookupChain(uniqueName); } else if (uniqueName.StartsWith("[Store].[Chain]")) { destUniqueName = LookupStoreChain(uniqueName); } else if (uniqueName.StartsWith("[Store].[Postal Code]")) { destUniqueName = LookupStorePostalCode(uniqueName); } else if (uniqueName.StartsWith("[Time].[Monthly]")) { destUniqueName = LookupTimeMonthly(uniqueName); } else if (uniqueName.StartsWith("[Time].[Weekly]")) { destUniqueName = LookupTimeWeekly(uniqueName); } else if (uniqueName.StartsWith("[Expand Compound Products]")) { destUniqueName = LookupExpandProductGroups(uniqueName); } // convert using map if (destUniqueName == null) { destUniqueName = _map.ConvertSchemaObjectUN(type, uniqueName); } } // lookup dest object (if matched) if (destUniqueName == null || SourceSchemaMap.LookupAdomdSchemaObject(_destCube, type, destUniqueName) == null) { destUniqueName = null; if (!_srcUnmatched.Contains(uniqueName) && !_destUnmatched.Contains(uniqueName)) { _destUnmatched.Add(uniqueName); } row.ObjectsInvalidNew++; } // diff row.InvalidDiff = (row.ObjectsInvalidNew - row.ObjectsInvalid); // return return(destUniqueName == null ? uniqueName : destUniqueName); }