Beispiel #1
0
        // Specify what you want to happen when the Elapsed event is raised.
        void myTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                //Set the analytics account
                log.Info("Setting account...");
                _Adapter = new GtAccountAdapter();
                //Create the first account in the listAccounts.
                _Account = _Adapter.ConvertToGtAccount(_Section.AccountsItems[0]);
                log.Info("Account set...");
                //Register Analytics Service
                log.Info("OnStart: Set down Analytics Service...");
                _AnalyticsService = new GAnalyticsService(_Auth, _Account);
                log.Info("OnStart: Analytics Service On.");
                string xmlChoice = ConfigurationManager.AppSettings["SingleXml"];
                Int32  chosen    = Convert.ToInt32(xmlChoice);

                if (chosen == 1)
                {
                    _AnalyticsService.getAllSingleResults(_Account);
                }
                else
                {
                    _AnalyticsService.getAllResults(_Account);
                }
                //Writes in a xml file all the query responses.
                log.Info("Responses Retrieved...");
                log.Info("Displaying responses...");
            }
            catch (GDataRequestException ex)
            {
                log.Error("Excepción: " + ex.InnerException);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Handles the Click event of the btnRetrieveData control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnRetrieveData_Click(object sender, EventArgs e)
        {
            try
            {
                string comboIndex = cbAccounts.SelectedIndex.ToString();
                var    account    = _Section.AccountsItems[Convert.ToInt32(comboIndex)];
                _Account          = _Adapter.ConvertToGtAccount(account);
                _QueryDetailsList = _Account.Queries;
                //Create the Analytics Service. This will automatically call the previously registered authenticator.
                _Auth.Auth();
                _AnalyticsService = new GAnalyticsService(_Auth, _Account);
                List <String> accounts  = _AnalyticsService.getProfileIdList();
                string        xmlChoice = ConfigurationManager.AppSettings["SingleXml"];
                Int32         chosen    = Convert.ToInt32(xmlChoice);

                if (chosen == 1)
                {
                    _AnalyticsService.getAllSingleResults(_Account);
                }
                else
                {
                    _AnalyticsService.getAllResults(_Account);
                }
            }
            catch (GDataRequestException ex)
            {
                MessageBox.Show(ex.ResponseString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }