/* L O A D D A T A S O U R C E */ /*---------------------------------------------------------------------------- * %%Function: LoadDatasource * %%Qualified: AzLog.AzLogDatasourceSupport.LoadDatasource * %%Contact: rlittle * * Load the named datasource. This handles figuring out the datasource * type and loading the correct type. Regurns an interface to the datasource * ----------------------------------------------------------------------------*/ public static IAzLogDatasource LoadDatasource(AzLogModel azlm, string sRegRoot, string sName) { // first, figure out what type of datasource this is Settings.SettingsElt[] _rgsteeDatasource = { new Settings.SettingsElt("Type", Settings.Type.Str, "", ""), }; string sKey = String.Format("{0}\\Datasources\\{1}", sRegRoot, sName); // save everything we need to be able to recreate ourselves Settings ste = new Settings(_rgsteeDatasource, sKey, "ds"); ste.Load(); string sType = ste.SValue("Type"); DatasourceType dt; dt = TypeFromString(sType); switch (dt) { case DatasourceType.TextFile: return(AzLogFile.LoadFileDatasource(null, sRegRoot, sName)); case DatasourceType.AzureTable: return(AzLogAzureTable.LoadAzureDatasource(null, sRegRoot, sName)); case DatasourceType.AzureBlob: return(AzLogAzureBlob.LoadAzureDatasource(null, sRegRoot, sName)); default: throw new Exception("unknown datasourcetype"); } }
/* L O A D A Z U R E D A T A S O U R C E */ /*---------------------------------------------------------------------------- * %%Function: LoadAzureDatasource * %%Qualified: AzLog.AzLogAzureBlob.LoadAzureDatasource * %%Contact: rlittle * * Loads this azure datasource * ----------------------------------------------------------------------------*/ public static AzLogAzureBlob LoadAzureDatasource(AzLogModel azlm, string sRegRoot, string sName) { AzLogAzureBlob azla = new AzLogAzureBlob(); if (azla.FLoad(azlm, sRegRoot, sName)) { return(azla); } return(null); }
/* D O O P E N A C C O U N T */ /*---------------------------------------------------------------------------- * %%Function: DoOpenAccount * %%Qualified: AzLog.AzAddDatasource_Azure.DoOpenAccount * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ private void DoOpenAccount(object sender, EventArgs e) { if (m_cbStorageType.SelectedIndex == -1) { return; } m_lbTables.Items.Clear(); Settings ste = new Settings(_rgsteeAccount, KeyName, "main"); ste.Load(); DatasourceType dt = AzLogDatasourceSupport.TypeFromString(m_cbStorageType.Text); if (dt == DatasourceType.AzureBlob) { AzLogAzureBlob azla = new AzLogAzureBlob(); azla.OpenAccount( (string)m_cbAccounts.SelectedItem, AzLogAzureBlob.GetAccountKey(m_sRegRoot, (string)m_cbAccounts.SelectedItem)); foreach (string s in azla.Containers) { m_lbTables.Items.Add(s); } m_iazlds = azla; } else if (dt == DatasourceType.AzureTable) { AzLogAzureTable azlt = new AzLogAzureTable(); azlt.OpenAccount( (string)m_cbAccounts.SelectedItem, AzLogAzureTable.GetAccountKey(m_sRegRoot, (string)m_cbAccounts.SelectedItem)); foreach (string s in azlt.Tables) { m_lbTables.Items.Add(s); } m_iazlds = azlt; } }