コード例 #1
0
        /* 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);
        }
コード例 #2
0
        /* 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()));
            }
        }
コード例 #3
0
        /* F  L O A D */

        /*----------------------------------------------------------------------------
        *       %%Function: FLoad
        *       %%Qualified: AzLog.AzLogAzureTable.FLoad
        *       %%Contact: rlittle
        *
        *   Load the information about this datasource, but don't actually open it
        *   (doesn't ping the net or validate information)
        *  ----------------------------------------------------------------------------*/
        public bool FLoad(AzLogModel azlm, string sRegRoot, string sName)
        {
            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();
            m_sAccountName = ste.SValue("AccountName");
            m_sContainer   = ste.SValue("TableName");
            m_dt           = AzLogDatasourceSupport.TypeFromString(ste.SValue("Type"));
            m_sName        = sName;

            return(true);
        }
コード例 #4
0
        /* S A V E */

        /*----------------------------------------------------------------------------
        *       %%Function: Save
        *       %%Qualified: AzLog.AzLogAzureTable.Save
        *       %%Contact: rlittle
        *
        *   Save this datasource to the registry
        *  ----------------------------------------------------------------------------*/
        public void Save(string sRegRoot)
        {
            if (string.IsNullOrEmpty(m_sName))
            {
                throw new Exception("Cannot save empty datasource name");
            }

            string sKey = String.Format("{0}\\Datasources\\{1}", sRegRoot, m_sName);

            // save everything we need to be able to recreate ourselves
            Settings ste = new Settings(_rgsteeDatasource, sKey, "ds");

            ste.SetSValue("FileName", m_sFilename);
            ste.SetSValue("Type", AzLogDatasourceSupport.TypeToString(DatasourceType.TextFile));
            ste.Save();
        }
コード例 #5
0
        /* 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;
            }
        }
コード例 #6
0
        /* 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();
            }
        }