public void getAllSingleResults(GtAccount account) { List <GtQueryDetails> detailsList = new List <GtQueryDetails>(); detailsList = account.Queries; GtResultXmlSerializer serialize = new GtResultXmlSerializer(); String serializado = ""; string path = @ConfigurationManager.AppSettings["ResultPath"]; string filePath; if (!Directory.Exists(@ConfigurationManager.AppSettings["ResultPath"])) { Directory.CreateDirectory(@ConfigurationManager.AppSettings["ResultPath"]); } for (int i = 0; i < detailsList.Count(); i++) { String id = detailsList[i].TableId.ToString(); log.Info("Requesting:" + detailsList[i].Tittle); RetrievedData = GetStatistics(id, detailsList[i]); Result = getResult(RetrievedData, detailsList[i]); serializado = serialize.SerializeUtf8(Result); filePath = "result_" + detailsList[i].Name + ".xml"; StreamWriter file = new StreamWriter(path + filePath); file.Write(serializado); file.Close(); } }
public void getAllResults(GtAccount account) { List <GtQueryDetails> detailsList = new List <GtQueryDetails>(); detailsList = account.Queries; GtResultXmlSerializer serialize = new GtResultXmlSerializer(); String serializado = ""; List <GtResult> listResults = new List <GtResult>(); foreach (GtQueryDetails details in detailsList) { String id = details.TableId.ToString(); log.Info("Requesting:" + details.Tittle); RetrievedData = GetStatistics(id, details); Result = getResult(RetrievedData, details); listResults.Add(Result); } if (!Directory.Exists(@ConfigurationManager.AppSettings["ResultPath"])) { Directory.CreateDirectory(@ConfigurationManager.AppSettings["ResultPath"]); } serializado = serialize.SerializeUtf8(listResults); StreamWriter file = new StreamWriter(@ConfigurationManager.AppSettings["ResultPath"] + "result.xml"); file.Write(serializado); file.Close(); }
/// <summary> /// Handles the RowEnter event of the cbQueries control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.DataGridViewCellEventArgs"/> instance containing the event data.</param> private void cbAccounts_SelectedIndexChanged(object sender, EventArgs e) { GtAccount accountDetails = (GtAccount)cbAccounts.SelectedItem; GtAccountAdapter _Adapter = new GtAccountAdapter(); var section = _SettingsHandler.GetConfig(); _AccountList = _Adapter.ConvertToGtAccountList(section.AccountsItems); if (accountDetails == null) { throw new Exception("No account selected"); } }
/// <summary> /// Initialize and authenticate. This constructor create an object of GAnalyticsService, /// extended from AnalyticsService class and it tries to authentificate an user with /// the given credentials for a specific account. /// Attemps to authorize using the client login authorization mechanism to get the possibity of /// requesting data into a Google Analytics account and sets the account wich we like tracking. /// </summary> /// <param name="account", GtAccount>Pass the object GtAcccount created by reading the configuration section /// handler (GtSettingsHandler object), we need to get the user login, password and some query parameters from this object /// we will use later to do the specific requests.</param> /// <param name="auth"><code>Auth2Register</code>This object autheticates the application in the Google Auth2 Service</param> /// <exception cref="ArgumentNullException<Auth>"/> /// <exception cref="InvalidCredentials"/> public GAnalyticsService(Auth2Register auth, GtAccount account) : base("GTGATracker") { if (account == null) { throw new ArgumentNullException("account", "Account not set"); } if (string.IsNullOrEmpty(account.Email)) { throw new ArgumentNullException("email", "Email not set"); } if (string.IsNullOrEmpty(account.Password)) { throw new ArgumentNullException("password", "Password not set"); } this.Auth = auth; this._Account = account; }