public static string GetQueryValuesString(this AccountTrackInfo account) { var valuesStr = $@"('{account.AccountID}',{account.LastSpend.ToString()}, {((int)account.AccountType).ToString()}, '{account.SpendDate.ToString(Constants.AccountTrackInfos.DateFormat)}')"; return(valuesStr); }
public AccountTrackInfo GetAccountTrackInfo(int accountID, AccountType accountType) { try { var paramters = new DBParameter[] { new DBParameter($"@{Constants.AccountTrackInfos.AccountIDColumn}", accountID), new DBParameter($"@{Constants.AccountTrackInfos.AccountTypeColumn}", (int)accountType) }; var results = _dbHelper.ExecuteQuery(Constants.AccountTrackInfos.selectQueryTemplate, ConvertToAccountTrackInfo, _billingControllerDb, paramters); var account = new AccountTrackInfo(); if (results != null && results.Count == 1) { account = results[0]; } return(account); } catch (MySqlException ex) { throw new BillingControllerException($"Failed to get AccountSummaryInfo for account {accountID}", ex); } catch (Exception ex) { return(null); } }
private void OnAccountClosed(AccountClosed evt) { try { var accountsTracks = new List <AccountTrackInfo>(); var adGroupIds = new List <int>(); AccountTrackInfo accountTrackInfo = null; foreach (var pair in evt.AccountsSpends) { accountTrackInfo = new AccountTrackInfo { AccountID = Utilities.GetAccountID(pair.Key), LastSpend = pair.Value, SpendDate = evt.ClosedDate, AccountType = Utilities.GetAccountType(pair.Key) }; accountsTracks.Add(accountTrackInfo); if (accountTrackInfo.AccountType == AccountType.AdGroup) { adGroupIds.Add(accountTrackInfo.AccountID); } } _repository.PersistAccountTrackInfos(accountsTracks); TriggerUpdateAdStatusEvents(adGroupIds, evt.ClosedReason); } catch (Exception ex) { _log.Error(ex); } }