private void ConstructFromXml(string dataSourcesXml, bool clientLoad, IDataProtection dataProtection) { XmlDocument xmlDocument = new XmlDocument(); try { XmlUtil.SafeOpenXmlDocumentString(xmlDocument, dataSourcesXml); } catch (XmlException ex) { throw new MalformedXmlException(ex); } try { foreach (XmlNode childNode in (xmlDocument.SelectSingleNode("/DataSources") ?? throw new InvalidXmlException()).ChildNodes) { DataSourceInfo dataSource = DataSourceInfo.ParseDataSourceNode(childNode, clientLoad, dataProtection); Add(dataSource); } } catch (XmlException) { throw new InvalidXmlException(); } }
private DataSourceInfoCollection CombineOnSetDefinition(DataSourceInfoCollection newDataSources, bool keepOriginalDataSourceId, bool overrideOriginalConnectString) { DataSourceInfoCollection dataSourceInfoCollection = new DataSourceInfoCollection(); foreach (DataSourceInfo newDataSource in newDataSources) { DataSourceInfo byOriginalName = GetByOriginalName(newDataSource.OriginalName); if (byOriginalName == null) { dataSourceInfoCollection.Add(newDataSource); continue; } if (!keepOriginalDataSourceId) { byOriginalName.ID = newDataSource.ID; } if (overrideOriginalConnectString) { byOriginalName.SetOriginalConnectionString(newDataSource.OriginalConnectionStringEncrypted); byOriginalName.SetOriginalConnectStringExpressionBased(newDataSource.OriginalConnectStringExpressionBased); } dataSourceInfoCollection.Add(byOriginalName); } return(dataSourceInfoCollection); }
public void SetPasswordFromDataSourceInfo(DataSourceInfo dsInfo) { m_passwordEncrypted = dsInfo.m_passwordEncrypted; if (dsInfo.m_passwordSecureString != null) { m_passwordSecureString = new SecureStringWrapper(dsInfo.m_passwordSecureString); } }
public void AddOrUpdate(string key, DataSourceInfo dsInfo) { RSTrace.ProcessingTracer.Assert(key == ((dsInfo.OriginalName != null) ? dsInfo.OriginalName : string.Empty), "DataSourceInfo.AddOrUpdate: (dsInfo.OriginalName != null ? dsInfo.OriginalName : string.Empty)"); if (m_collection.ContainsKey(key)) { m_collection.Remove(key); } Add(dsInfo); }
public void AddOrUpdate(string key, DataSourceInfo dsInfo) { RSTrace.ProcessingTracer.Assert(key != null, "PowerViewDataSourceInfoCollection.AddOrUpdate: key != null"); if (m_dataSourceInfos.ContainsKey(key)) { m_dataSourceInfos.Remove(key); } m_dataSourceInfos.Add(key, dsInfo); }
public DataSetDefinition(DataSetCore dataSetCore, string description, DataSourceInfo dataSourceInfo, ParameterInfoCollection dataSetParameters) { m_dataSetCore = dataSetCore; m_description = description; m_dataSetParameters = dataSetParameters; if (dataSourceInfo != null && dataSourceInfo.IsReference) { m_sharedDataSourceReferenceId = dataSourceInfo.ID; } }
private void CheckedAddByPrompt(DataSourceInfo dataSource) { if (dataSource.CredentialsRetrieval == DataSourceInfo.CredentialsRetrievalOption.Prompt) { if (m_collectionByPrompt == null) { m_collectionByPrompt = new CollectionByPrompt(); } m_collectionByPrompt.CheckedAdd(dataSource); } }
internal void Add(DataSourceInfo dataSource, ServerDataSourceSettings serverDatasourceSettings) { string originalName = dataSource.OriginalName; Global.Tracer.Assert(m_collection[originalName] == null, "Collection already contains this data source."); dataSource.ThrowIfNotUsable(serverDatasourceSettings); m_collection.Add(originalName, dataSource); if (dataSource.NeedPrompt) { m_needPrompt = true; } }
private void AddToCollectionByID(DataSourceInfo dataSource) { if (m_collectionByID == null) { m_collectionByID = new Hashtable(); } else if (m_collectionByID.ContainsKey(dataSource.ID)) { return; } m_collectionByID.Add(dataSource.ID, dataSource); }
internal void Add(DataSourceInfo dataSource, ICatalogItemContext report) { if (Guid.Empty == dataSource.ID) { AddToCollectionByReport(dataSource, report); } else { AddToCollectionByID(dataSource); } CheckedAddByPrompt(dataSource); }
public void Add(DataSourceInfo dataSource) { if (dataSource.OriginalName == null) { RSTrace.ProcessingTracer.Assert(m_collection.Count == 0, "Adding more than one data source with null original name"); m_collection.Add("", dataSource); } else if (!m_collection.ContainsKey(dataSource.OriginalName)) { m_collection.Add(dataSource.OriginalName, dataSource); } }
public void CopyFrom(DataSourceInfo copy, string referencePath, Guid linkToCatalogItemId, bool isEmbeddedInModel) { LinkToStandAlone(copy, referencePath, linkToCatalogItemId); m_flags = copy.m_flags; m_modelID = copy.ModelID; m_modelLastUpdatedTime = copy.ModelLastUpdatedTime; m_isEmbeddedInModel = isEmbeddedInModel; if (isEmbeddedInModel) { IsModel = true; } }
public bool TryGetCachedDataSourceId(string dataSourceName, out Guid dataSourceId) { dataSourceId = Guid.Empty; DataSourceInfo byOriginalName = GetByOriginalName(dataSourceName); if (byOriginalName != null) { dataSourceId = byOriginalName.ID; return(true); } return(false); }
public DataSourceInfo(string name, string linkPath, Guid linkId, DataSourceInfo standAloneDatasource) { m_id = Guid.NewGuid(); m_name = name; m_originalName = name; m_DataSourceWithCredentialsId = standAloneDatasource.m_DataSourceWithCredentialsId; InitDefaultsOnCreation(); LinkToStandAlone(standAloneDatasource, linkPath, linkId); if (standAloneDatasource.IsModel) { IsModel = true; m_modelID = standAloneDatasource.ModelID; } }
public void LinkToStandAlone(DataSourceInfo standAlone, string standAlonePath, Guid standAloneCatalogItemId) { m_name = standAlone.m_name; m_extension = standAlone.m_extension; m_connectionStringEncrypted = standAlone.m_connectionStringEncrypted; m_dataSourceReference = standAlonePath; m_linkID = standAloneCatalogItemId; m_secDesc = standAlone.m_secDesc; m_credentialsRetrieval = standAlone.CredentialsRetrieval; m_prompt = standAlone.m_prompt; m_userNameEncrypted = standAlone.m_userNameEncrypted; m_passwordEncrypted = standAlone.m_passwordEncrypted; Enabled = standAlone.Enabled; ImpersonateUser = standAlone.ImpersonateUser; WindowsCredentials = standAlone.WindowsCredentials; }
public void LinkModelToDataSource(DataSourceInfo standAlone, Guid modelID) { m_DataSourceWithCredentialsId = standAlone.m_DataSourceWithCredentialsId; m_extension = standAlone.m_extension; m_connectionStringEncrypted = standAlone.m_connectionStringEncrypted; m_credentialsRetrieval = standAlone.CredentialsRetrieval; m_prompt = standAlone.Prompt; m_userNameEncrypted = standAlone.m_userNameEncrypted; m_passwordEncrypted = standAlone.m_passwordEncrypted; Enabled = standAlone.Enabled; ImpersonateUser = standAlone.ImpersonateUser; m_flags = standAlone.m_flags; m_modelID = modelID; m_isEmbeddedInModel = false; IsModel = true; }
public void AddSingleIfPrompt(DataSourceInfo dataSource, ServerDataSourceSettings serverDatasourceSettings) { Global.Tracer.Assert(dataSource.OriginalName == null, "Data source has non-null name when adding single"); if (m_collection.Count != 0) { throw new InternalCatalogException("Prompt collection is not empty when adding single data source"); } if (dataSource.CredentialsRetrieval == DataSourceInfo.CredentialsRetrievalOption.Prompt) { dataSource.ThrowIfNotUsable(serverDatasourceSettings); m_collection.Add("", dataSource); if (dataSource.NeedPrompt) { m_needPrompt = true; } } }
private void AddToCollectionByReport(DataSourceInfo dataSource, ICatalogItemContext report) { DataSourceInfoCollection dataSourceInfoCollection = null; if (m_collectionByReport == null) { m_collectionByReport = new Hashtable(); } else { dataSourceInfoCollection = (DataSourceInfoCollection)m_collectionByReport[report.StableItemPath]; } if (dataSourceInfoCollection == null) { dataSourceInfoCollection = new DataSourceInfoCollection(); m_collectionByReport.Add(report.StableItemPath, dataSourceInfoCollection); } dataSourceInfoCollection.Add(dataSource); }
public bool CredentialsAreSame(DatasourceCredentialsCollection creds, bool noCredentialsMeansSame, IDataProtection dataProtection) { if (noCredentialsMeansSame && (creds == null || creds.Count == 0)) { return(true); } if ((m_collectionByPrompt == null || m_collectionByPrompt.Count == 0) != (creds == null || creds.Count == 0)) { return(false); } if (creds == null || creds.Count == 0) { return(true); } if (creds.Count != m_collectionByPrompt.Count) { return(false); } foreach (DatasourceCredentials cred in creds) { DataSourceInfo representative = m_collectionByPrompt.GetBucketByOriginalName(cred.PromptID).GetRepresentative(); if (representative == null) { return(false); } if (representative.CredentialsRetrieval != DataSourceInfo.CredentialsRetrievalOption.Prompt) { return(false); } if (representative.GetPasswordDecrypted(dataProtection) != cred.Password) { return(false); } if (representative.GetUserName(dataProtection) != cred.UserName) { return(false); } } return(true); }
public DataSourceInfoCollection CombineOnSetDataSources(DataSourceInfoCollection newDataSources) { DataSourceInfoCollection dataSourceInfoCollection = new DataSourceInfoCollection(); foreach (DataSourceInfo newDataSource in newDataSources) { DataSourceInfo byOriginalName = GetByOriginalName(newDataSource.OriginalName); if (byOriginalName == null) { throw new DataSourceNotFoundException(newDataSource.OriginalName); } newDataSource.ID = byOriginalName.ID; newDataSource.SetOriginalConnectionString(byOriginalName.OriginalConnectionStringEncrypted); newDataSource.SetOriginalConnectStringExpressionBased(byOriginalName.OriginalConnectStringExpressionBased); dataSourceInfoCollection.Add(newDataSource); } IEnumerator enumerator = GetEnumerator(); try { while (enumerator.MoveNext()) { DataSourceInfo dataSourceInfo2 = (DataSourceInfo)enumerator.Current; if (newDataSources.GetByOriginalName(dataSourceInfo2.OriginalName) == null) { dataSourceInfoCollection.Add(dataSourceInfo2); } } return(dataSourceInfoCollection); } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } }
internal void SetCredentials(DatasourceCredentials credentials, IDataProtection dataProtection) { int num = 0; while (true) { if (num < Count) { DataSourceInfo dataSourceInfo = this[num]; if (dataSourceInfo.CredentialsRetrieval != DataSourceInfo.CredentialsRetrievalOption.Prompt) { break; } dataSourceInfo.SetUserName(credentials.UserName, dataProtection); dataSourceInfo.SetPassword(credentials.Password, dataProtection); num++; continue; } return; } throw new InternalCatalogException("Non-promptable data source appeared in prompt collection!"); }
public static DataSourceInfo ParseDataSourceNode(XmlNode node, bool clientLoad, bool allowNoName, IDataProtection dataProtection) { if (node.Name != "DataSource") { throw new InvalidXmlException(); } XmlNode xmlNode = node.SelectSingleNode("Name"); node.SelectSingleNode("Extension"); XmlNode xmlNode2 = node.SelectSingleNode("DataSourceDefinition"); XmlNode xmlNode3 = node.SelectSingleNode("DataSourceReference"); DataSourceInfo result = null; if ((!allowNoName && xmlNode == null) || xmlNode2 == null == (xmlNode3 == null)) { bool flag = true; if (clientLoad && node.SelectSingleNode("InvalidDataSourceReference") != null) { flag = false; result = new DataSourceInfo((xmlNode == null) ? "" : xmlNode.InnerText); } if (flag) { throw new InvalidXmlException(); } } string text = (xmlNode == null) ? "" : xmlNode.InnerText; if (xmlNode2 != null) { result = new DataSourceInfo(text, text, xmlNode2.OuterXml, dataProtection); } else if (xmlNode3 != null) { result = new DataSourceInfo(text, xmlNode3.InnerText, Guid.Empty); } return(result); }
internal void CheckedAdd(DataSourceInfo dataSource) { if (dataSource.CredentialsRetrieval != DataSourceInfo.CredentialsRetrievalOption.Prompt) { return; } PromptBucket bucketByLinkID = GetBucketByLinkID(dataSource.LinkID); PromptBucket bucketByOriginalName = GetBucketByOriginalName(dataSource.PromptIdentifier); if (bucketByLinkID == null) { if (bucketByOriginalName == null) { PromptBucket promptBucket = new PromptBucket(); promptBucket.Add(dataSource); Add(promptBucket); } else { bucketByOriginalName.Add(dataSource); } } else if (bucketByOriginalName == null) { bucketByLinkID.Add(dataSource); } else if (bucketByLinkID == bucketByOriginalName) { bucketByLinkID.Add(dataSource); } else { bucketByLinkID.AddRange(bucketByOriginalName); Remove(bucketByOriginalName); bucketByLinkID.Add(dataSource); } }
public string GetDomainName() { return(DataSourceInfo.GetDomainOnly(m_dp.UnprotectDataToString(m_encryptedDomainAndUserName, "UserName"))); }