Ejemplo n.º 1
0
        private async void editAndUpsertWithAccessConditionsButton_Click(object sender, EventArgs e)
        {
            try
            {
                AppDocument doc = GetDocFromUI();

                doc.Payload.Title = "SH " + DateTime.Now.TimeOfDay.ToString();

                var accessCondition = new AccessCondition()
                {
                    Condition = doc.ETag,
                    Type      = AccessConditionType.IfMatch
                };

                var requestOptions = new RequestOptions()
                {
                    PartitionKey    = new PartitionKey("2f1d80c0-f7bf-4d03-a3bb-500b430f800c"),
                    AccessCondition = accessCondition
                };

                var response = await client.UpsertDocumentAsync
                               (
                    DocumentCollectionUri,
                    doc,
                    requestOptions,
                    true
                               );

                MessageBox.Show(response.StatusCode.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public async Task SetAppMonitorDataAsync(AppDocument newDoc)
        {
            var id = await this.InsertDocumentAsync(this._monitorCollection, newDoc);

            this._currentMonitorId = id;
        }
        public async Task SetAppConfigAsync(AppDocument newDoc)
        {
            var id = await this.InsertDocumentAsync(this._configurationCollection, newDoc);

            this._currentConfigId = id;
        }
        private async Task <ObjectId> InsertDocumentAsync(IMongoCollection <AppDocument> collection, AppDocument newDoc)
        {
            newDoc.Created = DateTime.Now;
            await collection.InsertOneAsync(newDoc);

            var databaseName   = collection.Database.DatabaseNamespace.DatabaseName;
            var medatadataColl = this._database.GetCollection <MetadataDocument>(collection.CollectionNamespace.FullName.Replace(databaseName + ".", ""));
            var medadataDoc    = new MetadataDocument {
                LatestID = newDoc.Id
            };
            await medatadataColl.ReplaceOneAsync(item => item.Id == METADATA_ID, medadataDoc, new UpdateOptions { IsUpsert = true });

            return(newDoc.Id);
        }
Ejemplo n.º 5
0
 public async Task SetProductConfigAsync(string product, AppDocument newDoc)
 {
     await this._dao.GetAppDAO(product).SetAppConfigAsync(newDoc);
     await RaiseNotificationAsync(StoreNotificationType.Configuration, product, newDoc);
 }
Ejemplo n.º 6
0
 public async Task SetProductMonitorDataAsync(string product, AppDocument newDoc)
 {
     await this._dao.GetAppDAO(product).SetAppMonitorDataAsync(newDoc);
     await RaiseNotificationAsync(StoreNotificationType.Monitoring, product, newDoc);
 }
Ejemplo n.º 7
0
        public async Task RaiseNotificationAsync(StoreNotificationType notificationType, string product, AppDocument newDoc)
        {
            try
            {
                var listenersDict = await this.StateManager.GetOrAddAsync <IReliableDictionary <string, List <Uri> > >("ListenersDictionary");

                using (ITransaction tx = this.StateManager.CreateTransaction())
                {
                    List <Uri> newList = null;
                    var        result1 = await listenersDict.TryGetValueAsync(tx, notificationType.ToString());

                    if (result1.HasValue)
                    {
                        newList = new List <Uri>(result1.Value);
                    }
                    else
                    {
                        newList = new List <Uri>();
                    }

                    foreach (var listener in newList)
                    {
                        // This only creates a proxy object, it does not activate an actor or invoke any methods yet.
                        var myActor = ActorProxy.Create <IAdapter>(new ActorId(product), listener);

                        // This will invoke a method on the actor. If an actor with the given ID does not exist, it will be activated by this method call.
                        await myActor.NewAppConfigAvailable(newDoc);
                    }

                    await tx.CommitAsync();
                }
            }
            catch (Exception ex)
            {
                ServiceEventSource.Current.Message(ex.Message);
            }
        }
Ejemplo n.º 8
0
 public async Task SetProductMonitorData(string product, AppDocument newDoc)
 {
     await StoreServiceProxy?.SetProductMonitorDataAsync(product, newDoc);
 }
Ejemplo n.º 9
0
 public async Task SetProductConfig(string product, AppDocument newDoc)
 {
     await StoreServiceProxy?.SetProductConfigAsync(product, newDoc);
 }
 public async Task UpdateAppMonitoringData(AppDocument newDoc)
 {
     await StoreServiceProxy?.SetProductMonitorDataAsync(this.ProductName, newDoc);
 }
 public async Task NewAppConfigAvailable(AppDocument newDoc)
 {
     //TODO: Call proper ServiceProxy or ActorProxy for start/init application
 }