public SjaasWorker() { var docDbUri = "to-be-filled"; var docDbPrimaryKey = "to-be-filled"; var docDbClient = new DocumentClient(new Uri(docDbUri), docDbPrimaryKey); var database = "Sjaas"; var jobCollection = "Job"; var clusterCollection = "Cluster"; var sjaasDataStore = new CosmosDataStore(docDbClient, database, jobCollection, clusterCollection); var databricksClient = DatabricksClient.CreateClient("to-be-filled", "to-be-filled"); this.jobEventProcessor = new JobEventProcessor(sjaasDataStore, databricksClient); }
public CosmosSearchService( ISearchOptionsFactory searchOptionsFactory, CosmosDataStore cosmosDataStore, IQueryBuilder queryBuilder, IBundleFactory bundleFactory) : base(searchOptionsFactory, bundleFactory, cosmosDataStore) { EnsureArg.IsNotNull(cosmosDataStore, nameof(cosmosDataStore)); EnsureArg.IsNotNull(queryBuilder, nameof(queryBuilder)); _cosmosDataStore = cosmosDataStore; _queryBuilder = queryBuilder; }
async void btnDelete_Click(object sender, System.EventArgs e) { try { var cosmos = new CosmosDataStore(); await cosmos.DeleteAllMeetings(); lblCount.Text = "All meetings deleted"; } catch (Exception ex) { lblCount.Text = "An error occurred: " + ex.Message; } }
async void btnCount_Click2(object sender, System.EventArgs e) { try { var cosmos = new CosmosDataStore(); var count = await cosmos.MeetingCount(); lblCount.Text = "Meeting Count: " + count; } catch (Exception ex) { lblCount.Text = "An error occurred: " + ex.Message; } }
async void btnGenerate_Click(object sender, System.EventArgs e) { try { var cosmos = new CosmosDataStore(); var meeting = await cosmos.GenerateMeeting(); lblCode.Text = "CODE: " + meeting.Code; } catch (Exception ex) { lblConnected.Text = "An error occurred: " + ex.Message; } }
public void Setup() { var configBuilder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("secrets.json"); var config = configBuilder.Build(); var cosmosDataStoreSettings = new CosmosDataStoreSettings(); config.Bind(nameof(cosmosDataStoreSettings), cosmosDataStoreSettings); this.cosmosDataStore = new CosmosDataStore(cosmosDataStoreSettings); }
void btnCount_Click(object sender, System.EventArgs e) { try { var cosmos = new CosmosDataStore(); Task <long> task = cosmos.MeetingCount(); task.Wait(); long count = task.Result; lblCount.Text = "Meeting Count: " + count; } catch (Exception ex) { lblCount.Text = "An error occurred: " + ex.Message; } }
async void btnCountBooks_Click(object sender, System.EventArgs e) { try { var cosmos = new CosmosDataStore(); string id = await cosmos.SaveBook(); long count = await cosmos.BookCount(); lblCountBooks.Text = "Book Count Count: " + count; } catch (Exception ex) { lblCountBooks.Text = "An error occurred: " + ex.Message; } }
async void btnConnect_Click(object sender, System.EventArgs e) { try { var cosmos = new CosmosDataStore(); //var connected = await cosmos.ConnectTest(); await cosmos.StackOverflow(); lblConnected.Text = "Connected: true"; } catch (Exception ex) { lblConnected.Text = "An error occurred: " + ex.Message; Debug.WriteLine(ex.Message); } }
private static void InitService() { if (sjaasService != null) { return; } var docDbUri = "to-be-filled"; var docDbPrimaryKey = "to-be-filled"; var docDbClient = new DocumentClient(new Uri(docDbUri), docDbPrimaryKey); var database = "Sjaas"; var jobCollection = "Job"; var clusterCollection = "Cluster"; var sjaasDataStore = new CosmosDataStore(docDbClient, database, jobCollection, clusterCollection); sjaasService = new SjaasService(sjaasDataStore); }
public IntegrationTestCosmosDataStore() { _cosmosDataStoreConfiguration = new CosmosDataStoreConfiguration { Host = Environment.GetEnvironmentVariable("CosmosDb:Host") ?? CosmosDbLocalEmulator.Host, Key = Environment.GetEnvironmentVariable("CosmosDb:Key") ?? CosmosDbLocalEmulator.Key, DatabaseId = Environment.GetEnvironmentVariable("CosmosDb:DatabaseId") ?? "FhirTests", CollectionId = Guid.NewGuid().ToString(), AllowDatabaseCreation = true, PreferredLocations = Environment.GetEnvironmentVariable("CosmosDb:PreferredLocations")?.Split(';', StringSplitOptions.RemoveEmptyEntries), }; var updaters = new ICollectionUpdater[] { new CollectionSettingsUpdater(NullLogger <CollectionSettingsUpdater> .Instance, _cosmosDataStoreConfiguration), new StoredProcedureInstaller(), }; var dbLock = new CosmosDbDistributedLockFactory(Substitute.For <Func <IScoped <IDocumentClient> > >(), NullLogger <CosmosDbDistributedLock> .Instance); var upgradeManager = new CollectionUpgradeManager(updaters, _cosmosDataStoreConfiguration, dbLock, NullLogger <CollectionUpgradeManager> .Instance); IDocumentClientTestProvider testProvider = new DocumentClientReadWriteTestProvider(); var documentClientInitializer = new DocumentClientInitializer(testProvider, NullLogger <DocumentClientInitializer> .Instance, upgradeManager, Substitute.For <IFhirRequestContextAccessor>()); _documentClient = documentClientInitializer.CreateDocumentClient(_cosmosDataStoreConfiguration); documentClientInitializer.InitializeDataStore(_documentClient, _cosmosDataStoreConfiguration).GetAwaiter().GetResult(); var cosmosDocumentQueryFactory = new CosmosDocumentQueryFactory(Substitute.For <IFhirRequestContextAccessor>(), NullFhirDocumentQueryLogger.Instance); _dataStore = new CosmosDataStore( new NonDisposingScope(_documentClient), _cosmosDataStoreConfiguration, cosmosDocumentQueryFactory, new RetryExceptionPolicyFactory(_cosmosDataStoreConfiguration), NullLogger <CosmosDataStore> .Instance); }
public ItemsViewModel() { isStartup = true; Title = "Shopping Cart"; Items = new ObservableCollection <Item>(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); MessagingCenter.Subscribe <ImageView, Item>(this, "AddItem", async(obj, item) => { if (item == null) { Debug.WriteLine("new item is null!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } if (obj == null) { Debug.WriteLine("obj is null!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } Debug.WriteLine(obj.ToString()); Debug.WriteLine(item.ToString()); Items.Add(item); if (AccountViewModel.UserID != null) { item.Uid = AccountViewModel.UserID; item.Id = (Guid.NewGuid().ToString().GetHashCode() + Guid.NewGuid().ToString().GetHashCode() + Guid.NewGuid().ToString().GetHashCode() + Guid.NewGuid().ToString().GetHashCode()) / 4; if (!item.SourcePath.StartsWith("http")) // if source path is a local file path { // change the source path to a remote url behind the scene so that it can be stored in remote db await BlobService.AzureBlobService.UploadFileAsync(item.SourcePath, item); } // just save the url to cloud DB, no need for blob storage await CosmosDataStore.AddItemAsync(item); } else { bool result = await DataStore.AddItemAsync(item); if (!result) { Debug.WriteLine("CANNOT ADD NEW ITEM!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } } // var cachedImage = new CachedImage() // { // HorizontalOptions = LayoutOptions.Center, // VerticalOptions = LayoutOptions.Center, // WidthRequest = 256, // HeightRequest = 256, // CacheDuration = TimeSpan.FromDays(30), // DownsampleWidth = 256, // RetryCount = 0, // RetryDelay = 250, // TransparencyEnabled = false, // LoadingPlaceholder = "http://via.placeholder.com/256x256", // ErrorPlaceholder = "http://via.placeholder.com/256x256", // Source = item.ImageFilePath // }; }); MessagingCenter.Subscribe <ImageView, Item>(this, "EditItem", async(obj, item) => { Debug.WriteLine(obj.ToString()); Debug.WriteLine(item.ToString()); int index = Items.IndexOf(item); Items.Remove(item); Items.Insert(index, item); if (item.Uid != null) // it belongs to a authenticated user, not the local file system { await CosmosDataStore.UpdateItemAsync(item).ContinueWith(t => { Debug.WriteLine("Edit result : " + t.Result); LoadItemsCommand.Execute(null); }); } else { await DataStore.UpdateItemAsync(item).ContinueWith(t => { Debug.WriteLine("Edit result : " + t.Result); LoadItemsCommand.Execute(null); }); } }); }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); if (AccountViewModel.UserID != null) // authenticated mode { await CosmosDataStore.GetItemsAsync().ContinueWith(async t => { foreach (var item in t.Result) { Debug.WriteLine("Id: " + item.Id); Debug.WriteLine("Text (name) : " + (item.Text ?? "null")); Debug.WriteLine("Description: " + (item.Description ?? "null")); Debug.WriteLine("SourcePath: " + (item.SourcePath ?? "null")); Debug.WriteLine("ImageUrl: " + (item.ImageUrl ?? "null")); Debug.WriteLine("Quantity: " + item.Quantity); Debug.WriteLine("ImageFilePath: " + (item.ImageFilePath ?? "null")); Debug.WriteLine("Uid: " + (item.Uid ?? "null")); Debug.WriteLine("ImageFilePathVersion: " + (item.ImageFilePathVersion ?? "null")); Items.Add(item); } await DataStore.GetItemsAsync().ContinueWith(t1 => { t1.Result.ForEach(i => { Items.Add(i); }); if (isStartup && Items.Count == 0) { isStartup = false; MessagingCenter.Send(this, "EmptyCart", true); } else { isStartup = false; } }); }); } else // local mode { await DataStore.GetItemsAsync(true).ContinueWith(t => { foreach (var item in t.Result) { Debug.WriteLine("Id: " + item.Id); Debug.WriteLine("Text (name) : " + (item.Text ?? "null")); Debug.WriteLine("Description: " + (item.Description ?? "null")); Debug.WriteLine("SourcePath: " + (item.SourcePath ?? "null")); Debug.WriteLine("ImageUrl: " + (item.ImageUrl ?? "null")); Debug.WriteLine("Quantity: " + item.Quantity); Debug.WriteLine("ImageFilePath: " + (item.ImageFilePath ?? "null")); Debug.WriteLine("Uid: " + (item.Uid ?? "null")); Debug.WriteLine("ImageFilePathVersion: " + (item.ImageFilePathVersion ?? "null")); Items.Add(item); } if (isStartup && Items.Count == 0) { isStartup = false; MessagingCenter.Send(this, "EmptyCart", true); } else { isStartup = false; } }); } // debug printlns for blobs await BlobService.AzureBlobService.GetAllBlobUrisAsync(); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }