private void RegisterDevice(Guid applicationId, string deviceId, Guid adControlDeviceId) { var newAppDevice = new AppDevice(applicationId, deviceId, _appTitle) { AdControlDeviceId = adControlDeviceId }; _tableContext = new TableServiceContext(TableServiceUri, _credentials); _tableContext.AddObject(AppDeviceTableName, newAppDevice); _tableContext.BeginSaveChanges(SaveChangesOptions.ContinueOnError, SaveChangesCallback, null); }
public void ReportImpressionInfo(string pubId, string adUnitId) { // Reason to put this part of the code in a worker thread: // 1) CPU optimization // 2) WaitOne cannot happen in UI thread or else the whole app will be hual ThreadPool.QueueUserWorkItem( state => { _ipRefreshedEvent.WaitOne(); var newAppUsage = new AppUsage(_applicationId, _anid, _deviceId, _appTitle) { AdControlDeviceId = _adControlDeviceId, AdUnitId = adUnitId, AssemblyFileVersion = _assemblyVersion, IpAddress = _ipAddress, Country = _country, Region = _region, City = _city, Isp = _isp, PubId = pubId, Action = "Impress" }; _tableContext = new TableServiceContext(TableServiceUri, _credentials); _tableContext.AddObject(AppUsageTableName, newAppUsage); _tableContext.BeginSaveChanges(SaveChangesOptions.ContinueOnError, SaveChangesCallback, null); }); }
public void ReportAppReviewInfo(int rating, string reviewMessage) { ThreadPool.QueueUserWorkItem( state => { _ipRefreshedEvent.WaitOne(); var newAppReview = new AppReview(_applicationId, _deviceId, _appTitle, rating, reviewMessage) { IpAddress = _ipAddress, Country = _country, Region = _region, City = _city, Isp = _isp, }; _tableContext = new TableServiceContext(TableServiceUri, _credentials); _tableContext.AddObject(AppReviewTableName, newAppReview); _tableContext.BeginSaveChanges(SaveChangesOptions.ContinueOnError, SaveChangesCallback, null); }); }
public void ReportErrorInfo(string pubId, string adUnitId, string errorMessage) { ThreadPool.QueueUserWorkItem( state => { _ipRefreshedEvent.WaitOne(); var newAppUsage = new AppUsage(_applicationId, _anid, _deviceId, _appTitle) { AdControlDeviceId = _adControlDeviceId, AdUnitId = adUnitId, AssemblyFileVersion = _assemblyVersion, IpAddress = _ipAddress, Country = _country, Region = _region, City = _city, Isp = _isp, PubId = pubId, Action = "Error", Message = errorMessage }; _tableContext = new TableServiceContext(TableServiceUri, _credentials); _tableContext.AddObject(AppUsageTableName, newAppUsage); _tableContext.BeginSaveChanges(SaveChangesOptions.ContinueOnError, SaveChangesCallback, null); }); }
public void ReportEngagedInfo(string pubId, string adUnitId) { ThreadPool.QueueUserWorkItem( state => { _ipRefreshedEvent.WaitOne(); var newPartitionKey = (DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks).ToString("d19"); var newAppUsage = new AppUsage(newPartitionKey, _anid, _deviceId, _appTitle) { AdControlDeviceId = _adControlDeviceId, AdUnitId = adUnitId, AssemblyFileVersion = _assemblyVersion, IpAddress = _ipAddress, Country = _country, Region = _region, City = _city, Isp = _isp, PubId = pubId, Action = "Engaged" }; _tableContext = new TableServiceContext(TableServiceUri, _credentials); _tableContext.AddObject(AppUsageTableName, newAppUsage); _tableContext.BeginSaveChanges(SaveChangesOptions.ContinueOnError, SaveChangesCallback, null); }); }