Ejemplo n.º 1
0
 public void CheckedAdd(DataSourceInfo dataSource)
 {
     if (dataSource.CredentialsRetrieval == DataSourceInfo.CredentialsRetrievalOption.Prompt)
     {
         PromptBucket bucketByLinkID       = this.GetBucketByLinkID(dataSource.LinkID);
         PromptBucket bucketByOriginalName = this.GetBucketByOriginalName(dataSource.PromptIdentifier);
         if (bucketByLinkID == null)
         {
             if (bucketByOriginalName == null)
             {
                 PromptBucket promptBucket = new PromptBucket();
                 promptBucket.Add(dataSource);
                 this.Add(promptBucket);
             }
             else
             {
                 bucketByOriginalName.Add(dataSource);
             }
         }
         else if (bucketByOriginalName == null)
         {
             bucketByLinkID.Add(dataSource);
         }
         else if (bucketByLinkID == bucketByOriginalName)
         {
             bucketByLinkID.Add(dataSource);
         }
         else
         {
             bucketByLinkID.AddRange(bucketByOriginalName);
             this.Remove(bucketByOriginalName);
             bucketByLinkID.Add(dataSource);
         }
     }
 }
        public DataSourceInfo GetDataSourceFromKey(string key)
        {
            DataSourceInfo result = default(DataSourceInfo);

            this.m_dataSourceInfos.TryGetValue(key, out result);
            return(result);
        }
Ejemplo n.º 3
0
        public DataSourceInfoCollection CombineOnSetDataSources(DataSourceInfoCollection newDataSources)
        {
            DataSourceInfoCollection dataSourceInfoCollection = new DataSourceInfoCollection();

            foreach (DataSourceInfo newDataSource in newDataSources)
            {
                DataSourceInfo byOriginalName = this.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);
            }
            foreach (DataSourceInfo item in this)
            {
                DataSourceInfo byOriginalName2 = newDataSources.GetByOriginalName(item.OriginalName);
                if (byOriginalName2 == null)
                {
                    dataSourceInfoCollection.Add(item);
                }
            }
            return(dataSourceInfoCollection);
        }
Ejemplo n.º 4
0
        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
            {
                XmlNode xmlNode = xmlDocument.SelectSingleNode("/DataSources");
                if (xmlNode == null)
                {
                    throw new InvalidXmlException();
                }
                foreach (XmlNode childNode in xmlNode.ChildNodes)
                {
                    DataSourceInfo dataSource = DataSourceInfo.ParseDataSourceNode(childNode, clientLoad, dataProtection);
                    this.Add(dataSource);
                }
            }
            catch (XmlException)
            {
                throw new InvalidXmlException();
            }
        }
Ejemplo n.º 5
0
        private DataSourceInfoCollection CombineOnSetDefinition(DataSourceInfoCollection newDataSources, bool keepOriginalDataSourceId, bool overrideOriginalConnectString)
        {
            DataSourceInfoCollection dataSourceInfoCollection = new DataSourceInfoCollection();

            foreach (DataSourceInfo newDataSource in newDataSources)
            {
                DataSourceInfo byOriginalName = this.GetByOriginalName(newDataSource.OriginalName);
                if (byOriginalName == null)
                {
                    dataSourceInfoCollection.Add(newDataSource);
                }
                else
                {
                    if (!keepOriginalDataSourceId)
                    {
                        byOriginalName.ID = newDataSource.ID;
                    }
                    if (overrideOriginalConnectString)
                    {
                        byOriginalName.SetOriginalConnectionString(newDataSource.OriginalConnectionStringEncrypted);
                        byOriginalName.SetOriginalConnectStringExpressionBased(newDataSource.OriginalConnectStringExpressionBased);
                    }
                    dataSourceInfoCollection.Add(byOriginalName);
                }
            }
            return(dataSourceInfoCollection);
        }
Ejemplo n.º 6
0
        public DataSourceInfo(string name, string originalName, string dataSourceDefinition, IDataProtection dataProtection)
            : this(name, originalName)
        {
            XmlDocument xmlDocument = new XmlDocument();
            XmlNode     xmlNode     = null;

            try
            {
                XmlUtil.SafeOpenXmlDocumentString(xmlDocument, dataSourceDefinition);
            }
            catch (XmlException ex)
            {
                throw new MalformedXmlException(ex);
            }
            try
            {
                xmlNode = xmlDocument.SelectSingleNode("/DataSourceDefinition");
                if (xmlNode == null)
                {
                    XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(xmlDocument.NameTable);
                    xmlNamespaceManager.AddNamespace("rds", DataSourceInfo.GetXmlNamespace());
                    xmlNode = xmlDocument.SelectSingleNode("/rds:" + DataSourceInfo.GetDataSourceDefinitionXmlTag(), xmlNamespaceManager);
                }
            }
            catch (XmlException)
            {
                throw new InvalidXmlException();
            }
            this.ParseAndValidate(xmlNode, dataProtection);
        }
Ejemplo n.º 7
0
 public void SetPasswordFromDataSourceInfo(DataSourceInfo dsInfo)
 {
     this.m_passwordEncrypted = dsInfo.m_passwordEncrypted;
     if (dsInfo.m_passwordSecureString != null)
     {
         this.m_passwordSecureString = new SecureStringWrapper(dsInfo.m_passwordSecureString);
     }
 }
Ejemplo n.º 8
0
 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 (this.m_collection.ContainsKey(key))
     {
         this.m_collection.Remove(key);
     }
     this.Add(dsInfo);
 }
 public void AddOrUpdate(string key, DataSourceInfo dsInfo)
 {
     RSTrace.ProcessingTracer.Assert(key != null, "PowerViewDataSourceInfoCollection.AddOrUpdate: key != null");
     if (this.m_dataSourceInfos.ContainsKey(key))
     {
         this.m_dataSourceInfos.Remove(key);
     }
     this.m_dataSourceInfos.Add(key, dsInfo);
 }
Ejemplo n.º 10
0
 public DataSetDefinition(DataSetCore dataSetCore, string description, DataSourceInfo dataSourceInfo, ParameterInfoCollection dataSetParameters)
 {
     this.m_dataSetCore       = dataSetCore;
     this.m_description       = description;
     this.m_dataSetParameters = dataSetParameters;
     if (dataSourceInfo != null && dataSourceInfo.IsReference)
     {
         this.m_sharedDataSourceReferenceId = dataSourceInfo.ID;
     }
 }
Ejemplo n.º 11
0
 private void CheckedAddByPrompt(DataSourceInfo dataSource)
 {
     if (dataSource.CredentialsRetrieval == DataSourceInfo.CredentialsRetrievalOption.Prompt)
     {
         if (this.m_collectionByPrompt == null)
         {
             this.m_collectionByPrompt = new CollectionByPrompt();
         }
         this.m_collectionByPrompt.CheckedAdd(dataSource);
     }
 }
Ejemplo n.º 12
0
 public void Add(DataSourceInfo dataSource, ICatalogItemContext report)
 {
     if (Guid.Empty == dataSource.ID)
     {
         this.AddToCollectionByReport(dataSource, report);
     }
     else
     {
         this.AddToCollectionByID(dataSource);
     }
     this.CheckedAddByPrompt(dataSource);
 }
        public void Add(DataSourceInfo dataSource, ServerDataSourceSettings serverDatasourceSettings)
        {
            string originalName = dataSource.OriginalName;

            Global.Tracer.Assert(this.m_collection[originalName] == null, "Collection already contains this data source.");
            dataSource.ThrowIfNotUsable(serverDatasourceSettings);
            this.m_collection.Add(originalName, dataSource);
            if (dataSource.NeedPrompt)
            {
                this.m_needPrompt = true;
            }
        }
Ejemplo n.º 14
0
        public bool TryGetCachedDataSourceId(string dataSourceName, out Guid dataSourceId)
        {
            dataSourceId = Guid.Empty;
            DataSourceInfo byOriginalName = this.GetByOriginalName(dataSourceName);

            if (byOriginalName != null)
            {
                dataSourceId = byOriginalName.ID;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 15
0
 private void AddToCollectionByID(DataSourceInfo dataSource)
 {
     if (this.m_collectionByID == null)
     {
         this.m_collectionByID = new Hashtable();
     }
     else if (this.m_collectionByID.ContainsKey(dataSource.ID))
     {
         return;
     }
     this.m_collectionByID.Add(dataSource.ID, dataSource);
 }
Ejemplo n.º 16
0
 public void CopyFrom(DataSourceInfo copy, string referencePath, Guid linkToCatalogItemId, bool isEmbeddedInModel)
 {
     this.LinkToStandAlone(copy, referencePath, linkToCatalogItemId);
     this.m_flags   = copy.m_flags;
     this.m_modelID = copy.ModelID;
     this.m_modelLastUpdatedTime = copy.ModelLastUpdatedTime;
     this.m_isEmbeddedInModel    = isEmbeddedInModel;
     if (isEmbeddedInModel)
     {
         this.IsModel = true;
     }
 }
Ejemplo n.º 17
0
 public void Add(DataSourceInfo dataSource)
 {
     if (dataSource.OriginalName == null)
     {
         RSTrace processingTracer = RSTrace.ProcessingTracer;
         processingTracer.Assert(this.m_collection.Count == 0, "Adding more than one data source with null original name");
         this.m_collection.Add("", dataSource);
     }
     else if (!this.m_collection.ContainsKey(dataSource.OriginalName))
     {
         this.m_collection.Add(dataSource.OriginalName, dataSource);
     }
 }
Ejemplo n.º 18
0
 public DataSourceInfo(string name, string linkPath, Guid linkId, DataSourceInfo standAloneDatasource)
 {
     this.m_id           = Guid.NewGuid();
     this.m_name         = name;
     this.m_originalName = name;
     this.m_DataSourceWithCredentialsId = standAloneDatasource.m_DataSourceWithCredentialsId;
     this.InitDefaultsOnCreation();
     this.LinkToStandAlone(standAloneDatasource, linkPath, linkId);
     if (standAloneDatasource.IsModel)
     {
         this.IsModel   = true;
         this.m_modelID = standAloneDatasource.ModelID;
     }
 }
Ejemplo n.º 19
0
 public void LinkModelToDataSource(DataSourceInfo standAlone, Guid modelID)
 {
     this.m_DataSourceWithCredentialsId = standAlone.m_DataSourceWithCredentialsId;
     this.m_extension = standAlone.m_extension;
     this.m_connectionStringEncrypted = standAlone.m_connectionStringEncrypted;
     this.m_credentialsRetrieval      = standAlone.CredentialsRetrieval;
     this.m_prompt            = standAlone.Prompt;
     this.m_userNameEncrypted = standAlone.m_userNameEncrypted;
     this.m_passwordEncrypted = standAlone.m_passwordEncrypted;
     this.Enabled             = standAlone.Enabled;
     this.ImpersonateUser     = standAlone.ImpersonateUser;
     this.m_flags             = standAlone.m_flags;
     this.m_modelID           = modelID;
     this.m_isEmbeddedInModel = false;
     this.IsModel             = true;
 }
Ejemplo n.º 20
0
 public void LinkToStandAlone(DataSourceInfo standAlone, string standAlonePath, Guid standAloneCatalogItemId)
 {
     this.m_name      = standAlone.m_name;
     this.m_extension = standAlone.m_extension;
     this.m_connectionStringEncrypted = standAlone.m_connectionStringEncrypted;
     this.m_dataSourceReference       = standAlonePath;
     this.m_linkID  = standAloneCatalogItemId;
     this.m_secDesc = standAlone.m_secDesc;
     this.m_credentialsRetrieval = standAlone.CredentialsRetrieval;
     this.m_prompt            = standAlone.m_prompt;
     this.m_userNameEncrypted = standAlone.m_userNameEncrypted;
     this.m_passwordEncrypted = standAlone.m_passwordEncrypted;
     this.Enabled             = standAlone.Enabled;
     this.ImpersonateUser     = standAlone.ImpersonateUser;
     this.WindowsCredentials  = standAlone.WindowsCredentials;
 }
 public void AddSingleIfPrompt(DataSourceInfo dataSource, ServerDataSourceSettings serverDatasourceSettings)
 {
     Global.Tracer.Assert(dataSource.OriginalName == null, "Data source has non-null name when adding single");
     if (this.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);
         this.m_collection.Add("", dataSource);
         if (dataSource.NeedPrompt)
         {
             this.m_needPrompt = true;
         }
     }
 }
Ejemplo n.º 22
0
        private void AddToCollectionByReport(DataSourceInfo dataSource, ICatalogItemContext report)
        {
            DataSourceInfoCollection dataSourceInfoCollection = null;

            if (this.m_collectionByReport == null)
            {
                this.m_collectionByReport = new Hashtable();
            }
            else
            {
                dataSourceInfoCollection = (DataSourceInfoCollection)this.m_collectionByReport[report.StableItemPath];
            }
            if (dataSourceInfoCollection == null)
            {
                dataSourceInfoCollection = new DataSourceInfoCollection();
                this.m_collectionByReport.Add(report.StableItemPath, dataSourceInfoCollection);
            }
            dataSourceInfoCollection.Add(dataSource);
        }
Ejemplo n.º 23
0
        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)
                {
                    XmlNode xmlNode4 = node.SelectSingleNode("InvalidDataSourceReference");
                    if (xmlNode4 != 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);
        }
Ejemplo n.º 24
0
 public bool CredentialsAreSame(DatasourceCredentialsCollection creds, bool noCredentialsMeansSame, IDataProtection dataProtection)
 {
     if (noCredentialsMeansSame && (creds == null || creds.Count == 0))
     {
         return(true);
     }
     if ((this.m_collectionByPrompt == null || this.m_collectionByPrompt.Count == 0) != (creds == null || creds.Count == 0))
     {
         return(false);
     }
     if (creds != null && creds.Count != 0)
     {
         if (creds.Count != this.m_collectionByPrompt.Count)
         {
             return(false);
         }
         foreach (DatasourceCredentials cred in creds)
         {
             DataSourceInfo representative = this.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);
     }
     return(true);
 }
Ejemplo n.º 25
0
        public void SetCredentials(DatasourceCredentials credentials, IDataProtection dataProtection)
        {
            int num = 0;

            while (true)
            {
                if (num < this.Count)
                {
                    DataSourceInfo dataSourceInfo = this[num];
                    if (dataSourceInfo.CredentialsRetrieval == DataSourceInfo.CredentialsRetrievalOption.Prompt)
                    {
                        dataSourceInfo.SetUserName(credentials.UserName, dataProtection);
                        dataSourceInfo.SetPassword(credentials.Password, dataProtection);
                        num++;
                        continue;
                    }
                    break;
                }
                return;
            }
            throw new InternalCatalogException("Non-promptable data source appeared in prompt collection!");
        }
Ejemplo n.º 26
0
        public string GetDomainName()
        {
            string domainAndUserName = this.m_dp.UnprotectDataToString(this.m_encryptedDomainAndUserName, "UserName");

            return(DataSourceInfo.GetDomainOnly(domainAndUserName));
        }
Ejemplo n.º 27
0
        public string GetDomainOnly(IDataProtection dataProtection)
        {
            string userName = this.GetUserName(dataProtection);

            return(DataSourceInfo.GetDomainOnly(userName));
        }
Ejemplo n.º 28
0
 public static DataSourceInfo ParseDataSourceNode(XmlNode node, bool clientLoad, IDataProtection dataProtection)
 {
     return(DataSourceInfo.ParseDataSourceNode(node, clientLoad, false, dataProtection));
 }
Ejemplo n.º 29
0
 private void SetOriginalConnectionString(string connectionString, IDataProtection dataProtection)
 {
     this.SetConnectionStringUseridReference(DataSourceInfo.HasUseridReference(connectionString));
     this.m_originalConnectionStringEncrypted = dataProtection.ProtectData(connectionString, "OriginalConnectionString");
 }
Ejemplo n.º 30
0
 public void SetConnectionString(string connectionString, IDataProtection dataProtection)
 {
     this.SetConnectionStringUseridReference(DataSourceInfo.HasUseridReference(connectionString));
     this.m_connectionStringEncrypted = dataProtection.ProtectData(connectionString, "ConnectionString");
 }