public async Task <IOperationResult> Update(UpdateOperation <User> model)
        {
            try
            {
                var entityToUpdate = _repository.Find <User>(x => x.Id == model.Entity.Id);
                if (entityToUpdate == null)
                {
                    throw new Exception($"{model?.Entity?.GetType()?.Name ?? "Entity"} to update was not found.");
                }

                entityToUpdate.FirstName = model.Entity.FirstName;
                entityToUpdate.LastName  = model.Entity.LastName;
                entityToUpdate.Email     = model.Entity.Email;
                entityToUpdate.Roles     = model.Entity.Roles;

                _repository.Update(entityToUpdate);

                await _repository.SaveChangesAsync();

                await _repository.AggregateEntityHistory(entityToUpdate.Id, model.UserId, OperationType.Update);

                return(OperationResult.Success);
            }
            catch (Exception ex)
            {
                return(OperationResult.Failed(ex.Message));
            }
        }
        public void ValidateCollapse_UpdateOperation_OK()
        {
            var sut   = new InsertOperation("test", "1234");
            var newOp = new UpdateOperation("test", "1234");

            sut.ValidateOperationCanCollapse(newOp);
        }
        public void Collapse_MismatchedItemId_Throws()
        {
            var sut   = new InsertOperation("test", "1234");
            var newOp = new UpdateOperation("test", "4321");

            Assert.Throws <ArgumentException>(() => sut.CollapseOperation(newOp));
        }
Example #4
0
        // (This region of code is not in normal use as of 3-30-2020)
        internal static UpdateOperation GetNewBookUpdateOperation()
        {
            var updateOp = new UpdateOperation();

            AddUpdateSource(updateOp);
            return(updateOp);
        }
Example #5
0
        /// <summary>
        /// Runs an <see cref="UpdateOperation"/> on the dependencies contained in a <see cref="XmlDocument"/> loaded from a .nuspec file.
        /// </summary>
        /// <param name="document"></param>
        /// <param name="operation"></param>
        /// <returns></returns>
        public static IEnumerable <UpdateOperation> UpdateDependencies(
            this XmlDocument document,
            UpdateOperation operation
            )
        {
            var operations = new List <UpdateOperation>();

            foreach (var node in document.SelectElements("dependency", $"[@id='{operation.PackageId}']"))
            {
                var versionNodeValue = node.GetAttribute("version");

                // only nodes with explicit version, skip expansion.
                if (!versionNodeValue.Contains("{", System.StringComparison.OrdinalIgnoreCase))
                {
                    var currentOperation = operation.WithPreviousVersion(versionNodeValue);

                    if (currentOperation.ShouldProceed())
                    {
                        node.SetAttribute("version", currentOperation.UpdatedVersion.ToString());
                    }

                    operations.Add(currentOperation);
                }
            }

            return(operations);
        }
Example #6
0
        /// <summary>
        /// Runs an <see cref="UpdateOperation"/> on the PackageReferences contained in a <see cref="XmlDocument"/>.
        /// </summary>
        /// <param name="document"></param>
        /// <param name="operation"></param>
        /// <returns></returns>
        public static IEnumerable <UpdateOperation> UpdatePackageReferences(
            this XmlDocument document,
            UpdateOperation operation
            )
        {
            var operations = new List <UpdateOperation>();

            var packageId = operation.PackageId;

            var packageReferences   = document.SelectElements("PackageReference", $"[@Include='{packageId}' or @Update='{packageId}']");
            var dotnetCliReferences = document.SelectElements("DotNetCliToolReference", $"[@Include='{packageId}' or @Update='{packageId}']");

            foreach (var packageReference in packageReferences.Concat(dotnetCliReferences))
            {
                var packageVersion = packageReference.GetAttributeOrChild("Version");

                if (packageVersion.HasValue())
                {
                    var currentOperation = operation.WithPreviousVersion(packageVersion);

                    if (currentOperation.ShouldProceed())
                    {
                        packageReference.SetAttributeOrChild("Version", currentOperation.UpdatedVersion.ToString());
                    }

                    operations.Add(currentOperation);
                }
            }

            return(operations);
        }
 /// <summary>
 /// default constructor: initializes all members
 /// </summary>
 public UpdateOpInfo()
 {
     title = "";
     ID = "";
     date = DateTime.MinValue;
     operation = UpdateOperation.uoUninstallation;
     result = OperationResultCode.orcNotStarted;
 }
        public void Deserialize_Works_WithoutItem()
        {
            var expected  = new UpdateOperation("test", "1234");
            var operation = TableOperation.Deserialize(serializedObject);

            Assert.IsAssignableFrom <UpdateOperation>(operation);
            Assert.Equal(expected, operation);
        }
        public void Write(UpdateOperation <T> value, IMsgPackWriter writer)
        {
            writer.WriteArrayHeader(3);

            _stringConverter.Write(value.OperationType, writer);
            _intConverter.Write(value.FieldNumber, writer);
            _argumentConverter.Write(value.Argument, writer);
        }
        public void Operation_CanBeCancelled()
        {
            var operation = new UpdateOperation("test", "1234");

            Assert.False(operation.IsCancelled);
            operation.Cancel();
            Assert.True(operation.IsCancelled);
        }
Example #11
0
        public object Update(UpdateOperation value)
        {
            Type   type;
            object instance;

            ResolveTypeAndInstance(value, out type, out instance);
            return(Repository.Update(type, instance));
        }
Example #12
0
        UpdateResult <JSONDocument> IDocumentStore.UpdateDocument(UpdateOperation operation)
        {
            UsageStats stats = new UsageStats();

            stats.BeginSample();

            UpdateResult <JSONDocument> result = new UpdateResult <JSONDocument>();
            CacheItem cItem;

            if (!_cache.ContainsKey(operation.RowId))
            {
                //TODO: Read-through
                if (!_persistenceManager.MetadataIndex(_parent.Name).ContainsRowId(operation.RowId))
                {
                    if (LoggerManager.Instance.StorageLogger != null && LoggerManager.Instance.StorageLogger.IsWarnEnabled)
                    {
                        LoggerManager.Instance.StorageLogger.Warn("Update : document not found.", "Document not found while updating in metadataIndex. rowId = " + operation.RowId + " collection = " + Name);
                    }
                    AddFailedOperation(operation);
                    return(result);
                }

                cItem = LoadDocument(operation.RowId, operation.Context);
            }
            else
            {
                cItem = CacheGet(operation.RowId);//_cache[operation.RowId];
            }
            if (cItem == null)
            {
                throw new Exception("Item not found in cache.");
            }
            //removing cache item from eviction policy so that it will not be evicted.
            _evictionPolicy.Remove(operation.RowId, cItem.EvictionHint);
            result.OldDocument = cItem.Document.Clone() as JSONDocument;
            cItem.Document     = operation.Update;
            result.RowId       = operation.RowId;
            result.NewDocument = cItem.Document.Clone() as JSONDocument;

            cItem.Flag.SetBit(BitsetConstants.DocumentDirty);


            _indexManager.UpdateIndex(operation.RowId, cItem.Document, operation.Update, operation.OperationId);

            PersistenceOperation persistenceOperation = new PersistenceUpdateOperation(operation.OperationId,
                                                                                       _parent.Name, operation.RowId, cItem, operation.Context);

            AddToPersistenceDictionary(persistenceOperation);
            _parent.MetadataIndex.Update(new DocumentKey(operation.Update.Key), operation);
            if (_statsCollector != null)
            {
                stats.EndSample();
                _statsCollector.IncrementStatsValue(StatisticsType.AvgUpdateTime, stats.Current);
                _statsCollector.IncrementStatsValue(StatisticsType.UpdatesPerSec);
            }

            return(result);
        }
        public void Operation_CanBeUpdated()
        {
            var operation = new UpdateOperation("test", "1234");

            Assert.False(operation.IsUpdated);
            operation.Update();
            Assert.Equal(2, operation.Version);
            Assert.True(operation.IsUpdated);
        }
        public void Operation_CanSetItem()
        {
            var operation = new UpdateOperation("test", "1234")
            {
                Item = testObject
            };

            Assert.Equal(operation.Item, testObject);
        }
Example #15
0
        /// <summary>
        /// Checks against the old database version to see which fields/properties have been updated and need to be written to the database
        /// Note: Any dynamic objects are probably going to get updated every time. It's hard to compare them.
        /// </summary>
        /// <returns>UpdateOperation with the necessary updates</returns>
        internal virtual UpdateOperation GetPendingUpdates()
        {
            var pendingUpdates       = new UpdateOperation();
            var type                 = this.GetType();
            var writeableMemberNames = this.GetWriteableMembers();

            List <MemberInfo> fieldsAndProperties =
                // First collect all the fields and properties
                type.GetFields().Cast <MemberInfo>()
                .Concat(type.GetProperties().Cast <MemberInfo>())
                // Only include those columns which are explicitly marked as writeable
                .Where(member => writeableMemberNames.Contains(member.Name))
                // Only include the ones which are serialized to JSON
                .Where(member => member.CustomAttributes.Any(attr => attr.AttributeType.FullName == "Newtonsoft.Json.JsonPropertyAttribute"))
                .ToList();

            // Iterate over and process each automatically handled field/property
            // to see if its value has been modified since the last time we read/wrote to the database
            foreach (var memberInfo in fieldsAndProperties)
            {
                object oldValue;
                object newValue;

                if (memberInfo is FieldInfo)
                {
                    var fieldInfo = (FieldInfo)memberInfo;
                    oldValue = fieldInfo.GetValue(this.DatabaseVersion);
                    newValue = fieldInfo.GetValue(this);
                }
                else
                {
                    // We know that everything here is supposed to be either a FieldInfo or PropertyInfo,
                    // so if it's not FieldInfo, it should be a propertyInfo
                    var propertyInfo = (PropertyInfo)memberInfo;

                    if (this.DatabaseVersion == null)
                    {
                        oldValue = null;
                    }
                    else
                    {
                        oldValue = propertyInfo.GetValue(this.DatabaseVersion);
                    }

                    newValue = propertyInfo.GetValue(this);
                }

                // Record an update if the value has been modified
                if (!AreObjectsEqual(oldValue, newValue))
                {
                    string propertyName = GetMemberJsonName(memberInfo);
                    pendingUpdates.UpdateFieldWithObject(propertyName, newValue);
                }
            }

            return(pendingUpdates);
        }
        public void GetHashCode_Works()
        {
            var sut = new UpdateOperation("test", "1234")
            {
                Item = testObject
            };
            var hash = "1234".GetHashCode();

            Assert.Equal(hash, sut.GetHashCode());
        }
        public void Serialize_Works_WithoutItem()
        {
            var operation = new UpdateOperation("test", "1234");

            JObject actual = operation.Serialize();

            actual.Remove("id");

            Assert.Equal(serializedObject, actual);
        }
        public async Task ExecuteOnOfflineStore_Throws_WithItemNotInStore()
        {
            var store = new Mock <IOfflineStore>();

            store.Setup(x => x.GetItemAsync("test", "1234", It.IsAny <CancellationToken>())).Returns(Task.FromResult((JObject)null));
            store.Setup(x => x.UpsertAsync("test", It.IsAny <IEnumerable <JObject> >(), It.IsAny <bool>(), It.IsAny <CancellationToken>())).Returns(Task.CompletedTask);
            var sut = new UpdateOperation("test", "1234");

            await Assert.ThrowsAsync <OfflineStoreException>(() => sut.ExecuteOperationOnOfflineStoreAsync(store.Object, testObject));
        }
        public void Collapse_UpdateOperation()
        {
            var sut   = new UpdateOperation("test", "1234");
            var newOp = new UpdateOperation("test", "1234");

            sut.CollapseOperation(newOp);

            Assert.False(sut.IsCancelled);
            Assert.True(sut.IsUpdated);
            Assert.True(newOp.IsCancelled);
        }
Example #20
0
        private void ProcessOneBook(Book book)
        {
            try
            {
                _logger.TrackEvent("ProcessOneBook Start");
                string message = $"Processing: {book.BaseUrl}";
                Console.Out.WriteLine(message);
                _logger.LogVerbose(message);

                var initialUpdates = new UpdateOperation();
                initialUpdates.UpdateField(Book.kHarvestStateField, Book.HarvestState.InProgress.ToString());
                initialUpdates.UpdateField(Book.kHarvesterIdField, this.Identifier);

                var startTime = new Parse.Model.Date(DateTime.UtcNow);
                initialUpdates.UpdateField("harvestStartedAt", startTime.ToJson());

                _parseClient.UpdateObject(book.GetParseClassName(), book.ObjectId, initialUpdates.ToJson());

                // Process the book
                var finalUpdates = new UpdateOperation();
                var warnings     = FindBookWarnings(book);
                finalUpdates.UpdateField(Book.kWarningsField, Book.ToJson(warnings));

                // ENHANCE: Do more processing here

                // Write the updates
                finalUpdates.UpdateField(Book.kHarvestStateField, Book.HarvestState.Done.ToString());
                _parseClient.UpdateObject(book.GetParseClassName(), book.ObjectId, finalUpdates.ToJson());

                _logger.TrackEvent("ProcessOneBook End - Success");
            }
            catch (Exception e)
            {
                YouTrackIssueConnector.SubmitToYouTrack(e, $"Unhandled exception thrown while processing book \"{book.BaseUrl}\"");

                // Attempt to write to Parse that processing failed
                if (!String.IsNullOrEmpty(book?.ObjectId))
                {
                    try
                    {
                        var onErrorUpdates = new UpdateOperation();
                        onErrorUpdates.UpdateField(Book.kHarvestStateField, $"\"{Book.HarvestState.Failed.ToString()}\"");
                        onErrorUpdates.UpdateField(Book.kHarvesterIdField, this.Identifier);
                        _parseClient.UpdateObject(book.GetParseClassName(), book.ObjectId, onErrorUpdates.ToJson());
                    }
                    catch (Exception)
                    {
                        // If it fails, just let it be and throw the first exception rather than the nested exception.
                    }
                }
                throw;
            }
        }
        public async Task ExecuteRemote_CallsRemoteServer_ThrowsWhenInvalidResponse()
        {
            var client = GetMockClient();

            MockHandler.AddResponse(HttpStatusCode.OK, new string[] { "test" });

            var sut = new UpdateOperation("test", "1234")
            {
                Item = testObject
            };
            await Assert.ThrowsAsync <DatasyncInvalidOperationException>(() => sut.ExecuteOperationOnRemoteServiceAsync(client));
        }
        public async Task ExecuteRemote_ThrowsError_WithNoItem()
        {
            var client = GetMockClient();

            MockHandler.AddResponse(HttpStatusCode.OK);

            var sut       = new UpdateOperation("test", "1234");
            var exception = await Assert.ThrowsAsync <DatasyncInvalidOperationException>(() => sut.ExecuteOperationOnRemoteServiceAsync(client));

            Assert.Empty(MockHandler.Requests);
            Assert.Contains("must have an item", exception.Message);
        }
Example #23
0
        static async Task DoWork()
        {
            using (var box = await Box.Connect(
                       "operator:123123@localhost:3301"))
            {
                var schema = box.GetSchema();

                var space = await schema.GetSpace("users");

                var primaryIndex = await space.GetIndex("primary_id");

                //await space.Insert(TarantoolTuple.Create(Guid.NewGuid().ToString(),
                //"Vladimir Vladimirov", "vvladimirov", "*****@*****.**", 10L));

                var updatedData = await space.Update <TarantoolTuple <string>,
                                                      TarantoolTuple <string, string, string, string, long> >(
                    TarantoolTuple.Create("600ca93b-10dc-4ebe-8c78-95f4d5384426"),
                    new UpdateOperation[] { UpdateOperation.CreateAssign(4, 47L) });

                var data = await primaryIndex.Select <TarantoolTuple <string>,
                                                      TarantoolTuple <string, string, string, string, long> >(
                    TarantoolTuple.Create(String.Empty), new SelectOptions
                {
                    Iterator = Iterator.All
                });

                var loginIndex = await space.GetIndex("secondary_login");

                var users = await loginIndex.Select <TarantoolTuple <string>,
                                                     TarantoolTuple <string, string, string, string, long> >(
                    TarantoolTuple.Create("petrov"));

                var petrov = users.Data;

                var ratingIndex = await space.GetIndex("secondary_rating");

                var ratingUsers = await ratingIndex.Select <TarantoolTuple <long>,
                                                            TarantoolTuple <string, string, string, string, long> >(
                    TarantoolTuple.Create(15L), new SelectOptions
                {
                    Iterator = Iterator.Ge
                });

                await box.Call("update_rating");

                foreach (var item in data.Data)
                {
                    Console.WriteLine(item);
                }
            }
        }
        /// <summary>
        /// Given the collection of available update scripts (which were added before either by explicitly calling
        /// <see cref="AddUpdateScript"/> or by calling <see cref="AddDirectory"/>), this methods updates the sub schema
        /// of this class in the database to the current version.
        /// </summary>
        /// <remarks>
        /// The update is an iterative process. In each step, an update script will be applied which matches the current
        /// subschema version.
        /// If the subschema isn't present in the DB before this method gets called (i.e. its current version isn't present),
        /// the first step will be to apply the "Create" script (i.e. the script with an empty "from" version).
        /// If the subschema currently is at version A.B, potential update scripts are those with a
        /// "from" version of "A.*" or "A.B". "A.*" will be preferrably used. The DB update will take place with the script
        /// which was found (if any) and the next update step starts. If no more matching update script is found,
        /// the update terminates.
        /// </remarks>
        /// <param name="newVersionMajor">Returns the subschema major version after the execution of this method.</param>
        /// <param name="newVersionMinor">Returns the subschema minor version after the execution of this method.</param>
        /// <returns><c>true</c>, if the requested ,
        /// else <c>false</c>.</returns>
        public bool UpdateSubSchema(out int newVersionMajor, out int newVersionMinor)
        {
            IDatabaseManager databaseManager = ServiceRegistration.Get <IDatabaseManager>();
            int curVersionMajor = 0;
            int curVersionMinor = 0;

            try
            {
                // Create schema
                if (!databaseManager.GetSubSchemaVersion(_subSchemaName, out curVersionMajor, out curVersionMinor))
                {
                    CreateOperation createOperation = GetCreateOperation();
                    if (createOperation == null)
                    {
                        return(false); // No schema could be created
                    }
                    databaseManager.UpdateSubSchema(_subSchemaName, null, null,
                                                    createOperation.CreateScriptFilePath, createOperation.ToVersionMajor, createOperation.ToVersionMinor);
                    curVersionMajor = createOperation.ToVersionMajor;
                    curVersionMinor = createOperation.ToVersionMinor;
                }
                while (true)
                {
                    UpdateOperation nextOperation = GetUpdateOperation(curVersionMajor, curVersionMinor);
                    if (nextOperation == null)
                    {
                        break;
                    }
                    // Avoid busy loops on wrong input data
                    if (nextOperation.ToVersionMajor < curVersionMajor ||
                        (nextOperation.ToVersionMajor == curVersionMajor && nextOperation.ToVersionMinor < curVersionMinor))
                    {
                        throw new ArgumentException(string.Format("Update script '{0}' seems to decrease the schema version",
                                                                  nextOperation.UpdateScriptFilePath));
                    }
                    databaseManager.UpdateSubSchema(_subSchemaName, curVersionMajor, curVersionMinor,
                                                    nextOperation.UpdateScriptFilePath, nextOperation.ToVersionMajor, nextOperation.ToVersionMinor);
                    curVersionMajor = nextOperation.ToVersionMajor;
                    curVersionMinor = nextOperation.ToVersionMinor;
                }
                ServiceRegistration.Get <ILogger>().Info("DatabaseSubSchemaManager: Subschema '{0}' present in version {1}.{2}",
                                                         _subSchemaName, curVersionMajor, curVersionMinor);
                return(true);
            }
            finally
            {
                newVersionMajor = curVersionMajor;
                newVersionMinor = curVersionMinor;
            }
        }
Example #25
0
        public void UpdateOperation_UpdateFieldWithObject_String_SameAsUpdateFieldWithString(string inputValue)
        {
            var updateOp1 = new UpdateOperation();

            updateOp1.UpdateFieldWithString("field", inputValue);
            string json1 = updateOp1.ToJson();

            var updateOp2 = new UpdateOperation();

            updateOp2.UpdateFieldWithObject("field", inputValue);
            string json2 = updateOp2.ToJson();

            Assert.AreEqual(json1, json2);
        }
Example #26
0
        private static string DecodeUpdateOperation(UpdateOperation updateOperation)
        {
            switch (updateOperation)
            {
            case UpdateOperation.ADD:
                return(OpAdd);

            case UpdateOperation.DEL:
                return(OpDel);

            default:
                return(OpAdd);
            }
        }
Example #27
0
        private IEnumerator Download()
        {
            _updater.Initialize(RemoteUrl, ProjectName, VersionFileName);

            yield return(_updater.LoadAllVersionFiles());

            yield return(_updater.UpdateFromStreamingAsset());

            _updateOperation = _updater.UpdateFromRemoteAsset();
            _totalCount      = _updateOperation.RemainBundleCount;
            yield return(_updateOperation);

            StartGameButton.gameObject.SetActive(true);
        }
Example #28
0
        public void Collapse_CancelsExistingOperation_WithUpdateOperation()
        {
            var newOperation = new UpdateOperation("test", MobileServiceTableKind.Table, "abc");

            this.operation.Collapse(newOperation);

            // new operation should be cancelled
            Assert.IsTrue(newOperation.IsCancelled);

            // existing operation should be updated and not cancelled
            Assert.IsFalse(this.operation.IsCancelled);
            Assert.IsTrue(this.operation.IsUpdated);
            Assert.AreEqual(this.operation.Version, 2);
        }
Example #29
0
        public void UpdateOperation_AddsInts_DeserializesCorrectly()
        {
            // Setup
            var updateOp = new UpdateOperation();

            updateOp.UpdateFieldWithNumber("field1", "19");

            // System under test
            string resultJson = updateOp.ToJson();

            // Verify
            string expectedJson = "{\"field1\":19}";

            Assert.AreEqual(expectedJson, resultJson);
        }
        public void Equals_TableOperation_Works()
        {
            var sut = new UpdateOperation("test", "1234")
            {
                Item = testObject
            };
            var other = new UpdateOperation("test", "1234")
            {
                Item = testObject
            };
            var notother = new DeleteOperation("test", "1234");

            Assert.True(sut.Equals(other));
            Assert.False(sut.Equals(notother));
        }
Example #31
0
 /// <summary>
 /// Repond Failure on the operation status result.
 /// </summary>
 /// <param name="subscriptionId">The subscription.</param>
 /// <param name="operationId">The operation location.</param>
 /// <param name="updateOperationStatus">The operation status to patch with.</param>
 /// <returns>
 /// Patch Operation Status Result.
 /// </returns>
 /// <exception cref="System.Exception">Error occurred while getting the operation result.</exception>
 public async Task <Response> PatchOperationStatusResultAsync(Guid subscriptionId, Guid operationId, UpdateOperationStatusEnum updateOperationStatus)
 {
     this.Logger?.Info($"Inside PatchOperationStatusResultAsync() of FulfillmentApiService, trying to Update Operation Status to { updateOperationStatus} Operation ID : {operationId} Subscription ID : {subscriptionId}");
     try
     {
         UpdateOperation updateOperation = new UpdateOperation();
         updateOperation.Status = updateOperationStatus;
         return(await this.marketplaceClient.Operations.UpdateOperationStatusAsync(subscriptionId, operationId, updateOperation));
     }
     catch (RequestFailedException ex)
     {
         this.ProcessErrorResponse(MarketplaceActionEnum.UPDATE_OPERATION_STATUS, ex);
         return(null);
     }
 }
Example #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrototypeBackend.SequencesUpdatedArgs"/> class.
 /// </summary>
 /// <param name="seqUpdateOperation">Seq update operation.</param>
 /// <param name="oldseq">The old sequence.</param>
 /// <param name="newseq">The new sequence.</param>
 public SequencesUpdatedArgs(UpdateOperation seqUpdateOperation, Sequence oldseq = null, Sequence newseq = null)
 {
     OldSeq = oldseq;
     NewSeq = newseq;
     UpdateOperation = seqUpdateOperation;
 }
 /// <summary>
 /// returns a human-readable string to describe the passed
 /// UpdateOperation value (e.g. "Installation" or "Uninstallation",
 /// depending on what the value indicates)
 /// </summary>
 /// <param name="value">UpdateOperation value that shall be represented
 /// as string</param>
 /// <returns>string that describes the update operation</returns>
 public static string UpdateOperationToString(UpdateOperation value)
 {
     switch (value)
     {
         case UpdateOperation.uoInstallation:
             return "Installation";
         case UpdateOperation.uoUninstallation:
             return "Uninstallation";
         default:
             return "unknown operation";
     } //switch
 }
Example #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrototypeBackend.ControllerPinUpdateArgs"/> class.
 /// </summary>
 /// <param name="oldpin">The old pin.</param>
 /// <param name="pinUpdateOperation">Pin update operation.</param>
 /// <param name="newpin">The new pin.</param>
 public ControllerPinUpdateArgs(IPin oldpin, UpdateOperation pinUpdateOperation, IPin newpin = null)
 {
     OldPin = oldpin;
     NewPin = newpin;
     UpdateOperation = pinUpdateOperation;
 }
Example #35
0
    /// <summary>
    /// Update the specified data.
    /// </summary>
    /// <param name='key'>
    /// The data key.
    /// </param>
    /// <param name='val'>
    /// The data value.
    /// </param>
    /// <param name='operation'>
    /// The operation type.
    /// </param>
    /// <param name='userData'>
    /// <c>true</c> if is user data; otherwise, <c>false</c>. Default false (i.e. game data).
    /// </param>
    public void Update(string key, string val, UpdateOperation operation, bool userData = false )
    {
        if (key.Trim () == string.Empty)
        {
            GJAPI.Instance.GJDebug ("Key is empty. Can't get data.", LogType.Error);
            return;
        }

        GJAPI.Instance.GJDebug ("Updating data.");

        Dictionary<string,string> parameters = new Dictionary<string, string> ();
        parameters.Add ("key", key);
        parameters.Add ("operation", operation.ToString ().ToLower ());
        parameters.Add ("format", "dump");

        Dictionary<string,string> postParameters = new Dictionary<string, string> ();
        postParameters.Add ("value", val);

        GJAPI.Instance.Request (DATA_UPDATE, parameters, postParameters, userData, ReadUpdateResponse);
    }
Example #36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrototypeBackend.MeasurementCombinationsUpdatedArgs"/> class.
 /// </summary>
 /// <param name="sigUpdateOperation">Sig update operation.</param>
 /// <param name="oldmecom">The old measurementcombination.</param>
 /// <param name="newmecom">The new measurementcombination.</param>
 public MeasurementCombinationsUpdatedArgs(UpdateOperation sigUpdateOperation, MeasurementCombination oldmecom = null, MeasurementCombination newmecom = null)
 {
     OldMeCom = oldmecom;
     NewMeCom = newmecom;
     UpdateOperation = sigUpdateOperation;
 }