/// <summary> /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.SQLiteEventStore"/> /// </summary> /// <param name="maConfig">Mobile Analytics Manager Configuration.</param> public SQLiteEventStore(MobileAnalyticsManagerConfig maConfig) { _maConfig = maConfig; #if BCL _dbFileFullPath = InternalSDKUtils.DetermineAppLocalStoragePath(dbFileName); #elif PCL _dbFileFullPath = System.IO.Path.Combine(PCLStorage.FileSystem.Current.LocalStorage.Path, dbFileName); #endif _logger.InfoFormat("Initialize SQLite event store. The SQLite DB file path is {0}.", _dbFileFullPath); SetupSQLiteEventStore(); }
internal static void ModifyDeleteRequest(IExecutionContext executionContext) { IRequest request = executionContext.get_RequestContext().get_Request(); IDictionary <string, string> headers = request.get_Headers(); IDictionary <string, string> parameters = request.get_Parameters(); if (InternalSDKUtils.get_IsAndroid() && request.get_HttpMethod() == "DELETE" && !parameters.ContainsKey("ContentType") && !headers.ContainsKey("Content-Type")) { headers.Add("Content-Type", "application/x-www-form-urlencoded"); } }
public Session(string appID, MobileAnalyticsManagerConfig maConfig) { _maConfig = maConfig; _appId = appID; #if BCL _sessionStorageFileName = InternalSDKUtils.DetermineAppLocalStoragePath(appID + _sessionStorageFileName); #elif PCL _sessionStorageFileFullPath = System.IO.Path.Combine(PCLStorage.FileSystem.Current.LocalStorage.Path, appID + _sessionStorageFileName); #endif _sessionStorage = new SessionStorage(); }
void ICoreAmazonS3.Delete(string bucketName, string objectKey, IDictionary <string, object> additionalProperties) { var request = new DeleteObjectRequest { BucketName = bucketName, Key = objectKey }; InternalSDKUtils.ApplyValues(request, additionalProperties); this.DeleteObject(request); }
public EnvironmentInfo() { this.Platform = Environment.OSVersion.Platform.ToString(); this.PlatformUserAgent = Environment.OSVersion.VersionString.Replace(" ", "_"); this.FrameworkUserAgent = string.Format(CultureInfo.InvariantCulture, ".NET_Runtime/{0}.{1} .NET_Framework/{2}", Environment.Version.Major, Environment.Version.MajorRevision, InternalSDKUtils.DetermineFramework()); }
Stream ICoreAmazonS3.GetObjectStream(string bucketName, string objectKey, IDictionary <string, object> additionalProperties) { var request = new GetObjectRequest() { BucketName = bucketName, Key = objectKey }; InternalSDKUtils.ApplyValues(request, additionalProperties); return(this.GetObject(request).ResponseStream); }
Task ICoreAmazonS3.DeleteAsync(string bucketName, string objectKey, IDictionary <string, object> additionalProperties, CancellationToken cancellationToken) { var request = new DeleteObjectRequest { BucketName = bucketName, Key = objectKey }; InternalSDKUtils.ApplyValues(request, additionalProperties); return(this.DeleteObjectAsync(request, cancellationToken)); }
IAsyncResult ICoreAmazonS3.BeginGetObjectStream(string bucketName, string objectKey, IDictionary <string, object> additionalProperties, AsyncCallback callback, object state) { var request = new GetObjectRequest() { BucketName = bucketName, Key = objectKey }; InternalSDKUtils.ApplyValues(request, additionalProperties); return(this.BeginGetObject(request, callback, state)); }
async Task <Stream> ICoreAmazonS3.GetObjectStreamAsync(string bucketName, string objectKey, IDictionary <string, object> additionalProperties, CancellationToken cancellationToken) { var request = new GetObjectRequest() { BucketName = bucketName, Key = objectKey }; InternalSDKUtils.ApplyValues(request, additionalProperties); return((await this.GetObjectAsync(request, cancellationToken).ConfigureAwait(false)).ResponseStream); }
public Session(string appID, MobileAnalyticsManagerConfig maConfig) { _maConfig = maConfig; _appID = appID; #if BCL _sessionStorageFileFullPath = InternalSDKUtils.DetermineAppLocalStoragePath(appID + _sessionStorageFileName); #elif PCL _sessionStorageFileFullPath = System.IO.Path.Combine(PCLStorage.FileSystem.Current.LocalStorage.Path, appID + _sessionStorageFileName); #endif _logger.InfoFormat("Initialize a new session. The session storage file is {0}.", _sessionStorageFileFullPath); _sessionStorage = new SessionStorage(); }
private static string GetAttributeReference(string attribute, Dictionary <string, string> attributeNames, ref int attributeCount) { string attributeReference; if (!InternalSDKUtils.TryFindByValue(attributeNames, attribute, StringComparer.Ordinal, out attributeReference)) { var variableName = GetVariableName(ref attributeCount); attributeReference = GetAttributeReference(variableName); attributeNames.Add(attributeReference, attribute); } return(attributeReference); }
public EnvironmentInfo() { this.Platform = UIDevice.CurrentDevice.SystemName; this.Model = UIDevice.CurrentDevice.Model; this.Make = "apple"; this.PlatformVersion = UIDevice.CurrentDevice.SystemVersion; this.Locale = NSLocale.AutoUpdatingCurrentLocale.LocaleIdentifier; this.FrameworkUserAgent = InternalSDKUtils.GetMonoRuntimeVersion(); this.PclPlatform = "PCL/Xamarin.iOS"; this.PlatformUserAgent = string.Format(CultureInfo.InstalledUICulture, "{0}_{1}", this.Platform.Replace(" ", string.Empty), this.PlatformVersion); }
void ICoreAmazonS3.UploadObjectFromStream(string bucketName, string objectKey, Stream stream, IDictionary <string, object> additionalProperties) { var transfer = new Amazon.S3.Transfer.TransferUtility(this); var request = new Amazon.S3.Transfer.TransferUtilityUploadRequest { BucketName = bucketName, Key = objectKey, InputStream = stream }; InternalSDKUtils.ApplyValues(request, additionalProperties); transfer.Upload(request); }
Task ICoreAmazonS3.UploadObjectFromStreamAsync(string bucketName, string objectKey, Stream stream, IDictionary <string, object> additionalProperties, CancellationToken cancellationToken) { var transfer = new Amazon.S3.Transfer.TransferUtility(this); var request = new Amazon.S3.Transfer.TransferUtilityUploadRequest { BucketName = bucketName, Key = objectKey, InputStream = stream }; InternalSDKUtils.ApplyValues(request, additionalProperties); return(transfer.UploadAsync(request, cancellationToken)); }
void ICoreAmazonS3.UploadObjectFromFilePath(string bucketName, string objectKey, string filepath, IDictionary <string, object> additionalProperties) { var transfer = new Amazon.S3.Transfer.TransferUtility(this); var request = new Amazon.S3.Transfer.TransferUtilityUploadRequest { BucketName = bucketName, Key = objectKey, FilePath = filepath }; InternalSDKUtils.ApplyValues(request, additionalProperties); transfer.Upload(request); }
public static void ClassInit(TestContext context) { #if BCL // This attribute must be set in BCL platform AWSConfigs.ApplicationName = "IntegrationTestApp"; // clean the session and db files left in last execution string appDataPath = InternalSDKUtils.DetermineAppLocalStoragePath(""); if (Directory.Exists(appDataPath)) { Directory.Delete(appDataPath, true); } #endif }
public EnvironmentInfo() { this.Platform = InternalSDKUtils.DetermineOS(); this.PlatformVersion = InternalSDKUtils.DetermineOSVersion(); this.PlatformUserAgent = InternalSDKUtils.PlatformUserAgent(); this.Model = "Unknown"; this.Make = "Unknown"; this.Locale = CultureInfo.CurrentCulture.DisplayName; this.FrameworkUserAgent = string.Format(CultureInfo.InvariantCulture, ".NET_Core/{0}", InternalSDKUtils.DetermineFramework()); this.PclPlatform = string.Empty; }
Task ICoreAmazonS3.DeletesAsync(string bucketName, IEnumerable <string> objectKeys, IDictionary <string, object> additionalProperties, CancellationToken cancellationToken) { var request = new DeleteObjectsRequest { BucketName = bucketName, }; foreach (var key in objectKeys) { request.AddKey(key); } InternalSDKUtils.ApplyValues(request, additionalProperties); return(this.DeleteObjectsAsync(request, cancellationToken)); }
void ICoreAmazonS3.Deletes(string bucketName, IEnumerable <string> objectKeys, IDictionary <string, object> additionalProperties) { var request = new DeleteObjectsRequest { BucketName = bucketName }; foreach (var key in objectKeys) { request.AddKey(key); } InternalSDKUtils.ApplyValues(request, additionalProperties); this.DeleteObjects(request); }
string ICoreAmazonS3.GeneratePreSignedURL(string bucketName, string objectKey, DateTime expiration, IDictionary <string, object> additionalProperties) { var request = new GetPreSignedUrlRequest { BucketName = bucketName, Key = objectKey, Expires = expiration }; InternalSDKUtils.ApplyValues(request, additionalProperties); return(this.GetPreSignedURL(request)); }
IAsyncResult ICoreAmazonS3.BeginUploadObjectFromFilePath(string bucketName, string objectKey, string filepath, IDictionary <string, object> additionalProperties, AsyncCallback callback, object state) { var transfer = new Amazon.S3.Transfer.TransferUtility(this); var request = new Amazon.S3.Transfer.TransferUtilityUploadRequest { BucketName = bucketName, Key = objectKey, FilePath = filepath }; InternalSDKUtils.ApplyValues(request, additionalProperties); return(transfer.BeginUpload(request, callback, state)); }
Task ICoreAmazonS3.DownloadToFilePathAsync(string bucketName, string objectKey, string filepath, IDictionary <string, object> additionalProperties, CancellationToken cancellationToken) { var transfer = new Amazon.S3.Transfer.TransferUtility(this); var request = new Amazon.S3.Transfer.TransferUtilityDownloadRequest { BucketName = bucketName, Key = objectKey, FilePath = filepath }; InternalSDKUtils.ApplyValues(request, additionalProperties); return(transfer.DownloadAsync(request, cancellationToken)); }
public EnvironmentInfo() { this.Platform = Environment.OSVersion.Platform.ToString(); this.PlatformVersion = Environment.OSVersion.Version.ToString(); this.PlatformUserAgent = Environment.OSVersion.VersionString.Replace(" ", "_"); this.Model = "Unknown"; this.Make = "Unknown"; this.Locale = CultureInfo.CurrentCulture.DisplayName; this.FrameworkUserAgent = string.Format(CultureInfo.InvariantCulture, ".NET_Runtime/{0}.{1} .NET_Framework/{2}", Environment.Version.Major, Environment.Version.MajorRevision, InternalSDKUtils.DetermineFramework()); this.PclPlatform = string.Empty; }
private static Dictionary <string, MemberInfo> GetMembersDictionary(ITypeInfo typeInfo) { Dictionary <string, MemberInfo> dictionary = new Dictionary <string, MemberInfo>(StringComparer.Ordinal); var members = typeInfo .GetMembers() .Where(IsValidMemberInfo) .ToList(); foreach (var member in members) { InternalSDKUtils.AddToDictionary(dictionary, member.Name, member); } return(dictionary); }
public static void SetAWSPowerShellUserAgent(System.Version hostVersion) { #if DESKTOP var moduleName = "AWSPowerShell"; var platform = "WindowsPowerShell"; #elif MODULAR var moduleName = "AWSPowerShell.Common"; var platform = "PowerShellCore"; #else var moduleName = "AWSPowerShell.NetCore"; var platform = "PowerShellCore"; #endif InternalSDKUtils.SetUserAgent(moduleName, TypeFactory.GetTypeInfo(typeof(BaseCmdlet)).Assembly.GetName().Version.ToString(), string.Format("{0}/{1}.{2}", platform, hostVersion.Major, hostVersion.MajorRevision)); }
public void RuntimeInformationTest() { var framework = InternalSDKUtils.DetermineFramework(); Assert.NotEqual("Unknown", framework); Assert.False(framework.Contains(" ")); var os = InternalSDKUtils.DetermineOS(); Assert.NotEqual("Unknown", os); Assert.False(os.Contains(" ")); var platform = InternalSDKUtils.PlatformUserAgent(); Assert.NotEqual("Unknown", platform); Assert.False(platform.Contains(" ")); }
private void UpdateAssemblyVersion() { var avi = new CoreAssemblyInfo { Session = session }; var text = avi.TransformText(); GeneratorDriver.WriteFile( Options.SdkRootFolder, corePath, assemblyInfoPath, text); var sdkUtil = new InternalSDKUtils { Session = session }; var sdkUtilText = sdkUtil.TransformText(); GeneratorDriver.WriteFile( Options.SdkRootFolder, corePath, internalSdkUtilPath, sdkUtilText); }
/// <summary> /// Sets up SQLite database. /// </summary> private void SetupSQLiteEventStore() { this.DBfileFullPath = InternalSDKUtils.DetermineAppLocalStoragePath(dbFileName); string vacuumCommand = "PRAGMA auto_vacuum = 1"; string sqlCommand = string.Format(CultureInfo.InvariantCulture, "CREATE TABLE IF NOT EXISTS {0} ({1} TEXT NOT NULL,{2} TEXT NOT NULL UNIQUE,{3} TEXT NOT NULL, {4} INTEGER NOT NULL DEFAULT 0 )", TABLE_NAME, EVENT_COLUMN_NAME, EVENT_ID_COLUMN_NAME, MA_APP_ID_COLUMN_NAME, EVENT_DELIVERY_ATTEMPT_COUNT_COLUMN_NAME); lock (_lock) { using (var connection = new SQLiteConnection("Data Source=" + this.DBfileFullPath + ";Version=3;")) { try { if (!File.Exists(this.DBfileFullPath)) { string directory = Path.GetDirectoryName(this.DBfileFullPath); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } SQLiteConnection.CreateFile(this.DBfileFullPath); } connection.Open(); using (var command = new SQLiteCommand(vacuumCommand, connection)) { command.ExecuteNonQuery(); } using (var command = new SQLiteCommand(sqlCommand, connection)) { command.ExecuteNonQuery(); } } finally { if (null != connection) { connection.Close(); } } } } }
/// <summary> /// Refreshes dataset metadata. Dataset metadata is pulled from remote /// storage and stored in local storage. Their record data isn't pulled down /// until you sync each dataset. /// </summary> /// <param name="callback">Callback once the refresh is complete</param> /// <param name="options">Options for asynchronous execution</param> /// <exception cref="Amazon.CognitoSync.SyncManager.DataStorageException">Thrown when fail to fresh dataset metadata</exception> public void RefreshDatasetMetadataAsync(AmazonCognitoSyncCallback <List <DatasetMetadata> > callback, AsyncOptions options = null) { options = options ?? new AsyncOptions(); remote.GetDatasetMetadataAsync((cognitoResult) => { Exception ex = cognitoResult.Exception; List <DatasetMetadata> res = cognitoResult.Response; if (ex != null) { InternalSDKUtils.AsyncExecutor(() => callback(cognitoResult), options); } else { Local.UpdateDatasetMetadata(GetIdentityId(), res); InternalSDKUtils.AsyncExecutor(() => callback(cognitoResult), options); } }, options); }
public void PutRecordsAsync(string datasetName, List <Record> records, string syncSessionToken, AmazonCognitoSyncCallback <List <Record> > callback, AsyncOptions options = null) { options = options ?? new AsyncOptions(); UpdateRecordsRequest request = new UpdateRecordsRequest(); request.DatasetName = datasetName; request.IdentityPoolId = identityPoolId; request.IdentityId = this.GetCurrentIdentityId(); request.SyncSessionToken = syncSessionToken; // create patches List <RecordPatch> patches = new List <RecordPatch>(); foreach (Record record in records) { patches.Add(this.RecordToPatch(record)); } request.RecordPatches = patches; List <Record> updatedRecords = new List <Record>(); client.UpdateRecordsAsync(request, (responseObj) => { Exception ex = responseObj.Exception; UpdateRecordsResponse updateRecordsResponse = responseObj.Response; Exception putRecordsException = null; object obj = responseObj.state; if (ex != null) { putRecordsException = HandleException(ex, "Failed to update records in dataset: " + datasetName); } else { foreach (Amazon.CognitoSync.Model.Record remoteRecord in updateRecordsResponse.Records) { updatedRecords.Add(ModelToRecord(remoteRecord)); } } InternalSDKUtils.AsyncExecutor(() => callback(new AmazonCognitoSyncResult <List <Record> >(updatedRecords, putRecordsException, obj)), options); }, options); }