/* D O A D D D A T A S O U R C E */ /*---------------------------------------------------------------------------- * %%Function: DoAddDatasource * %%Qualified: AzLog.AzLog.DoAddDatasource * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ private void DoAddDatasource(object sender, EventArgs e) { IAzLogDatasource iazlds = AzAddDatasource_Azure.CreateDatasource("Software\\Thetasoft\\AzLog"); if (iazlds != null) { iazlds.Save("Software\\Thetasoft\\AzLog"); m_lbAvailableDatasources.Items.Add(iazlds); } }
/* F A D D D A T A S O U R C E */ /*---------------------------------------------------------------------------- * %%Function: FAddDatasource * %%Qualified: AzLog.AzLogCollection.FAddDatasource * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ public bool FAddDatasource(string sDatasource, string sRegRoot) { IAzLogDatasource iazlds = AzLogDatasourceSupport.LoadDatasource(null, sRegRoot, sDatasource); if (iazlds != null) { return(FAddDatasource(iazlds)); } return(false); }
/* A Z A D D D A T A S O U R C E _ A Z U R E */ /*---------------------------------------------------------------------------- * %%Function: AzAddDatasource_Azure * %%Qualified: AzLog.AzAddDatasource_Azure.AzAddDatasource_Azure * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ public AzAddDatasource_Azure(string sRegRoot, IAzLogDatasource iazlds = null) { m_sRegRoot = sRegRoot; m_iazlds = iazlds; InitializeComponent(); PopulateAccounts(); if (m_iazlds != null) { m_ebName.Text = m_iazlds.GetName(); SelectCbItem(m_cbStorageType, AzLogDatasourceSupport.TypeToString(m_iazlds.GetSourceType())); } }
public static void EditDatasource(string sRegRoot, IAzLogDatasource iazlds) { AzAddDatasource_Azure azads = new AzAddDatasource_Azure(sRegRoot, iazlds); if (azads.ShowDialog() == System.Windows.Forms.DialogResult.OK) { azads.m_iazlds.SetName(azads.m_ebName.Text); //return azads.m_iazlds; } //return null; }
/* R E M O V E D A T A S O U R C E */ /*---------------------------------------------------------------------------- * %%Function: RemoveDatasource * %%Qualified: AzLog.AzLogCollection.RemoveDatasource * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ public void RemoveDatasource(IAzLogDatasource iazlds) { string sDatasource = iazlds.ToString(); for (int i = 0; i < m_pliazld.Count; i++) { if (string.Compare(sDatasource, m_pliazld[i].ToString(), true) == 0) { m_pliazld[i].Close(); m_pliazld.RemoveAt(i); return; } } }
/* D O R E M O V E D A T A S O U R C E */ /*---------------------------------------------------------------------------- * %%Function: DoRemoveDatasource * %%Qualified: AzLog.AzLog.DoRemoveDatasource * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ private void DoRemoveDatasource(object sender, EventArgs e) { if (m_azlc == null) { return; } IAzLogDatasource iazlds = (IAzLogDatasource)m_lbCollectionSources.SelectedItem; if (iazlds != null) { m_lbCollectionSources.Items.Remove(iazlds); m_azlc.RemoveDatasource(iazlds); // to happen against this datasource! } }
/* A T T A C H D A T A S O U R C E */ /*---------------------------------------------------------------------------- * %%Function: AttachDatasource * %%Qualified: AzLog.AzLogModel.AttachDatasource * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ public void AttachDatasource(IAzLogDatasource iazlds) { string sName = iazlds.GetName(); // make sure its not already there foreach (IAzLogDatasource iazldsT in m_pliazldsSources) { if (String.Compare(iazldsT.GetName(), sName, true) == 0) { throw new Exception("attaching the same datasource more than once"); } } m_pliazldsSources.Add(iazlds); iazlds.SetDatasourceIndex(m_pliazldsSources.Count - 1); }
/* 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; } }
/* D O I N C L U D E D A T A S O U R C E */ /*---------------------------------------------------------------------------- * %%Function: DoIncludeDatasource * %%Qualified: AzLog.AzLog.DoIncludeDatasource * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ private void DoIncludeDatasource(object sender, EventArgs e) { if (m_azlc == null) { return; } IAzLogDatasource iazlds = (IAzLogDatasource)m_lbAvailableDatasources.SelectedItem; if (iazlds != null) { if (m_azlc.FAddDatasource(iazlds)) { m_lbCollectionSources.Items.Add(iazlds); // TODO: If there's a model, then we should add it to the model, and cause a query // to happen against this datasource! } } }
/* P O P U L A T E D A T A S O U R C E S */ /*---------------------------------------------------------------------------- * %%Function: PopulateDatasources * %%Qualified: AzLog.AzLog.PopulateDatasources * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ public void PopulateDatasources() { RegistryKey rk = Registry.CurrentUser.OpenSubKey(String.Format("{0}\\Datasources", s_sRegRoot)); if (rk != null) { string[] rgs = rk.GetSubKeyNames(); foreach (string s in rgs) { // make sure the datasource is valid before we add it -- do this by just loading its // info from the registry (load doesn't connect to the datasource...) IAzLogDatasource iazlds = AzLogDatasourceSupport.LoadDatasource(null, s_sRegRoot, s); if (iazlds != null) { m_lbAvailableDatasources.Items.Add(iazlds); } } rk.Close(); } }
/* F E T C H P A R T I T I O N S F O R D A T E R A N G E */ /*---------------------------------------------------------------------------- * %%Function: FFetchPartitionsForDateRange * %%Qualified: AzLog.AzLogModel.FFetchPartitionsForDateRange * %%Contact: rlittle * * Fetch all the partitions in the given range. * ----------------------------------------------------------------------------*/ public bool FFetchPartitionsForDateRange(DateTime dttmMin, DateTime dttmMac) { DateTime dttm = dttmMin; while (dttm < dttmMac) { // if its complete or pending, don't query it again... if (m_azles.GetPartState(dttm) != AzLogPartState.Complete && m_azles.GetPartState(dttm) != AzLogPartState.Pending) { for (int i = 0; i < m_pliazldsSources.Count; i++) { IAzLogDatasource iazlds = m_pliazldsSources[i]; #if NOMORE // the marking of Pending happens in the FetchPartitionForDateAsync // if this ever comes back, then we will have to get the correct IDataSource. m_azles.UpdatePart(dttmMin, dttmMin.AddHours(1), AzLogParts.GrfDatasourceForIDatasource(1), AzLogPartState.Pending); #endif iazlds.FetchPartitionForDateAsync(this, dttm); } } dttm = dttm.AddHours(1); } return(true); }
/* F A D D D A T A S O U R C E */ /*---------------------------------------------------------------------------- * %%Function: FAddDatasource * %%Qualified: AzLog.AzLogCollection.FAddDatasource * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ public bool FAddDatasource(IAzLogDatasource iazlds) { m_pliazld.Add(iazlds); return(true); }