/// <summary> /// Converts a given <see cref="T:XElement"/> into a <see cref="T:ChangeSetHistory"/>. /// </summary> /// <param name="element">The <see cref="T:XElement"/> to convert.</param> /// <returns>The newly created <see cref="T:ChangeSetHistory"/>.</returns> public ChangeSetHistory FromXElement(XElement element) { ChangeSetHistory history = new ChangeSetHistory(); foreach (XElement changeSetElement in element.Nodes()) { ChangeSet changeSet = new ChangeSet(); // Get the change set details foreach (XElement changeSetElementChild in changeSetElement.Nodes()) { if (changeSetElementChild.Name.LocalName == "Applied") { changeSet.Applied = DateTime.Parse(changeSetElementChild.Value); } else if (changeSetElementChild.Name.LocalName == "Username") { changeSet.Username = changeSetElementChild.Value; } else if (changeSetElementChild.Name.LocalName == "Change") { Change change = new Change(); foreach (XElement changeElement in changeSetElementChild.Nodes()) { if (changeElement.Name.LocalName == "PropertyName") { change.PropertyName = changeElement.Value; } else if (changeElement.Name.LocalName == "OldValue") { change.OldValue = changeElement.Value; } else if (changeElement.Name.LocalName == "NewValue") { change.NewValue = changeElement.Value; } } changeSet.Changes.Add(change); } } history.Append(changeSet); } return history; }
public void ApplyChanges_ChildrenOnTypeChanged_PropertyInChangeSetIsChanged() { const TestEnum testEnumValue = TestEnum.ValueOne; const int testIntegerValue = 42; const string testStringValue = "The quick brown fox jumped over the lazy dog."; var testChildren = new[] { new TestObject() }; var testObject = new TestObject { TestEnum = testEnumValue, TestInteger = testIntegerValue, TestString = testStringValue, Children = new TestObject[0] }; dynamic changeSet = new ChangeSet<TestObject>(); changeSet.Children = testChildren; changeSet.ApplyChanges(ref testObject); Assert.That(testObject, Is.Not.Null); Assert.That(testObject.TestEnum, Is.EqualTo(testEnumValue)); Assert.That(testObject.TestInteger, Is.EqualTo(testIntegerValue)); Assert.That(testObject.TestString, Is.EqualTo(testStringValue)); Assert.That(testObject.Children, Is.EquivalentTo(testChildren)); }
public void advisoryBuilder_generateAdvisory_for_transient_and_changed_entity() { var expectedAction = ProposedActions.Create; var entity = new Object(); var entityState = EntityTrackingStates.IsTransient | EntityTrackingStates.AutoRemove | EntityTrackingStates.HasBackwardChanges; var c1 = MockRepository.GenerateStub<IChange>(); c1.Expect( obj => obj.GetChangedEntities() ).Return( new Object[] { entity } ); c1.Expect( obj => obj.GetAdvisedAction( entity ) ).Return( ProposedActions.Update | ProposedActions.Create ); c1.Replay(); var c2 = MockRepository.GenerateStub<IChange>(); c2.Expect( obj => obj.GetChangedEntities() ).Return( new Object[] { entity } ); c2.Expect( obj => obj.GetAdvisedAction( entity ) ).Return( ProposedActions.Update | ProposedActions.Create ); c2.Replay(); var cSet = new ChangeSet( new IChange[] { c1, c2 } ); var svc = MockRepository.GenerateStub<IChangeTrackingService>(); svc.Expect( obj => obj.GetEntityState( entity ) ).Return( entityState ); svc.Expect( obj => obj.GetEntities( EntityTrackingStates.IsTransient, true ) ).Return( new Object[ 0 ] ); svc.Replay(); var actual = new AdvisoryBuilder( new ChangeSetDistinctVisitor() ); IAdvisory advisory = actual.GenerateAdvisory( svc, cSet ); advisory.Should().Not.Be.Null(); advisory.Count.Should().Be.EqualTo( 1 ); advisory.First().Action.Should().Be.EqualTo( expectedAction ); advisory.First().Target.Should().Be.EqualTo( entity ); }
public OperationResult Post(string description, ChangeSet<ShoppingListItem> changes) { var item = this.GetItem(description); changes.Apply(item); return new OperationResult.SeeOther { RedirectLocation = item.CreateUri() }; }
public void Initialize() { ChangeSet = new ChangeSet(); ChangeSet.AddInsert(new object()); ChangeSet.AddUpdate(new object()); ChangeSet.AddDelete(new object()); }
/// <summary> /// Examine the list of operations after the service has finished, and determine what needs to /// be sent back to the client. /// </summary> /// <param name="changeSet">The change set processed.</param> /// <returns>The results list.</returns> private static List<ChangeSetEntry> GetSubmitResults(ChangeSet changeSet) { List<ChangeSetEntry> results = new List<ChangeSetEntry>(); foreach (ChangeSetEntry changeSetEntry in changeSet.ChangeSetEntries) { results.Add(changeSetEntry); if (changeSetEntry.HasError) { // if customErrors is turned on, clear out the stacktrace. // This is an additional step here so that ValidationResultInfo // and DomainService can remain agnostic to http-concepts HttpContext context = HttpContext.Current; if (context != null && context.IsCustomErrorEnabled) { if (changeSetEntry.ValidationErrors != null) { foreach (ValidationResultInfo error in changeSetEntry.ValidationErrors.Where(e => e.StackTrace != null)) { error.StackTrace = null; } } } } // Don't round-trip data that the client doesn't care about. changeSetEntry.Associations = null; changeSetEntry.EntityActions = null; changeSetEntry.OriginalAssociations = null; changeSetEntry.OriginalEntity = null; } return results; }
public static ChangeSet GenerateChangeSet(Config oldConfig, Config newConfig) { var cs = new ChangeSet(); foreach (var n in oldConfig) { var oldKey = n.Key; if (newConfig.ContainsKey(oldKey)) { var newNode = newConfig[oldKey]; if (n.Value != newNode) { cs.Add(new ConfigChange() { Type = ChangeType.Modified, Key = oldKey, Old = n.Value, New = newNode }); } } else { cs.Add(new ConfigChange() { Type = ChangeType.Removed, Key = oldKey, Old = n.Value, New = null }); } } foreach (var n in newConfig) { var newKey = n.Key; if (!oldConfig.ContainsKey(newKey)) { cs.Add(new ConfigChange() { Type = ChangeType.Added, Key = newKey, Old = null, New = newConfig[newKey] }); } } return cs; }
public void ApplyChanges_EnumPropertyOnTypeChanged_PropertyInChangeSetIsChanged() { const TestEnum testEnumValue = TestEnum.ValueOne; const int testIntegerValue = 42; const string testStringValue = "The quick brown fox jumped over the lazy dog."; var testIntegerEnumeration = new[] { 1, 2, 3, 4, 5 }; const TestEnum changedEnumValue = TestEnum.ValueTwo; var testObject = new TestObject { TestEnum = testEnumValue, TestInteger = testIntegerValue, TestString = testStringValue, TestIntegerEnumeration = testIntegerEnumeration }; dynamic changeSet = new ChangeSet<TestObject>(); changeSet.TestEnum = changedEnumValue; changeSet.ApplyChanges(ref testObject); Assert.That(testObject, Is.Not.Null); Assert.That(testObject.TestEnum, Is.EqualTo(changedEnumValue)); Assert.That(testObject.TestInteger, Is.EqualTo(testIntegerValue)); Assert.That(testObject.TestString, Is.EqualTo(testStringValue)); }
private string FormatMessage(ChangeSet change_set) { string message = "added ‘{0}’"; switch (change_set.Changes[0].Type) { case CmisChangeType.Edited: message = "edited ‘{0}’"; break; case CmisChangeType.Deleted: message = "deleted ‘{0}’"; break; case CmisChangeType.Moved: message = "moved ‘{0}’"; break; } if (change_set.Changes.Count == 1) { return message = string.Format(message, change_set.Changes[0].Path); } else if (change_set.Changes.Count > 1) { return string.Format(message + " and {0} more", change_set.Changes.Count - 1); } else { return "did something magical"; } }
public void It_appends_substring_of_comment_and_ellipsis_as_title_if_it_is_longer_than_30_characters() { var changeSet = new ChangeSet(ChangeSetId.NewUniqueId(), null, "Comment longer than 30 characters", new AbstractCommand[] { }); var model = CreateModel(changeSet); Assert.AreEqual("Comment longer than 30 char...", model.RootNodes[0].Title); }
public void It_appends_comment_as_title_if_it_is_shorter_or_equal_to_30_characters() { var changeSet = new ChangeSet(ChangeSetId.NewUniqueId(), null, "Comment with exactly 30 chars", new AbstractCommand[] { }); var model = CreateModel(changeSet); Assert.AreEqual("Comment with exactly 30 chars", model.RootNodes[0].Title); }
public override bool OnBeginCommit (ChangeSet changeSet) { // In this callback we check if the user information configured in Git // matches the user information configured in MonoDevelop. If the configurations // don't match, it shows a dialog asking the user what to do. GitRepository repo = (GitRepository) changeSet.Repository; Solution sol = null; // Locate the solution to which the changes belong foreach (Solution s in IdeApp.Workspace.GetAllSolutions ()) { if (s.BaseDirectory == changeSet.BaseLocalPath || changeSet.BaseLocalPath.IsChildPathOf (s.BaseDirectory)) { sol = s; break; } } if (sol == null) return true; string val = sol.UserProperties.GetValue<string> ("GitUserInfo"); if (val == "UsingMD") { // If the solution is configured to use the MD configuration, make sure the Git config is up to date. string user; string email; repo.GetUserInfo (out user, out email); if (user != sol.AuthorInformation.Name || email != sol.AuthorInformation.Email) repo.SetUserInfo (sol.AuthorInformation.Name, sol.AuthorInformation.Email); } else if (val != "UsingGIT") { string user; string email; repo.GetUserInfo (out user, out email); if (user != sol.AuthorInformation.Name || email != sol.AuthorInformation.Email) { // There is a conflict. Ask the user what to do string gitInfo = GetDesc (user, email); string mdInfo = GetDesc (sol.AuthorInformation.Name, sol.AuthorInformation.Email); UserInfoConflictDialog dlg = new UserInfoConflictDialog (mdInfo, gitInfo); try { if (dlg.Run () == (int) Gtk.ResponseType.Ok) { if (dlg.UseMonoDevelopConfig) { repo.SetUserInfo (sol.AuthorInformation.Name, sol.AuthorInformation.Email); sol.UserProperties.SetValue ("GitUserInfo", "UsingMD"); } else sol.UserProperties.SetValue ("GitUserInfo", "UsingGIT"); sol.SaveUserProperties (); } else return false; } finally { dlg.Destroy (); } } } return true; }
public override bool Initialize (ChangeSet changeSet) { if (changeSet.Repository is GitRepository) { pushCheckbox = new Gtk.CheckButton (GettextCatalog.GetString ("Push changes to remote repository after commit")); Add (pushCheckbox); ShowAll (); return true; } else return false; }
private static ChangeSetTreeNodeViewModel CreateNodeModel(ChangeSet changeSet, IEnumerable<ChangeSet> allChangeSets) { var children = allChangeSets.Where(x => x.ParentId == changeSet.Id); return new ChangeSetTreeNodeViewModel { Id = changeSet.Id.ToString(), Title = MakeTitle(changeSet), Children = children.Select(x => CreateNodeModel(x, allChangeSets)).ToList() }; }
public void Equality() { var a = new ChangeSet(new ChangeSetId(1, "123456")); Assert.Equal(a, a); var b = new ChangeSet(new ChangeSetId(1, "123456")); Assert.Equal(a, b); var c = new ChangeSet(new ChangeSetId(1, "789123")); Assert.NotEqual(a, c); }
public MeasurementCache(DatabaseTemplate template) { var values = new ChangeSet(); template.binaries.EachIndex((m, i) => values.Update(new Binary(Flags.RESTART), Convert.ToUInt16(i))); template.doubleBinaries.EachIndex((m, i) => values.Update(new DoubleBitBinary(Flags.RESTART), Convert.ToUInt16(i))); template.counters.EachIndex((m, i) => values.Update(new Counter(Flags.RESTART), Convert.ToUInt16(i))); template.frozenCounters.EachIndex((m, i) => values.Update(new FrozenCounter(Flags.RESTART), Convert.ToUInt16(i))); template.analogs.EachIndex((m, i) => values.Update(new Analog(Flags.RESTART), Convert.ToUInt16(i))); template.binaryOutputStatii.EachIndex((m, i) => values.Update(new BinaryOutputStatus(Flags.RESTART), Convert.ToUInt16(i))); template.analogOutputStatii.EachIndex((m, i) => values.Update(new AnalogOutputStatus(Flags.RESTART), Convert.ToUInt16(i))); template.timeAndIntervals.EachIndex((m, i) => values.Update(new TimeAndInterval(0, 0, IntervalUnits.Undefined), Convert.ToUInt16(i))); this.Load(values); }
public void changeSet_ctor() { var expected = new IChange[] { MockRepository.GenerateStub<IChange>(), MockRepository.GenerateStub<IChange>(), MockRepository.GenerateStub<IChange>() }; var actual = new ChangeSet( expected ); actual.Count.Should().Be.EqualTo( 3 ); actual.Should().Have.SameSequenceAs( expected ); }
/// <summary> /// Initializes this changeset source. /// </summary> public override void Initialize() { _next = null; _ser_create = new XmlSerializer(typeof(Osm.Xml.v0_6.create)); _ser_modify = new XmlSerializer(typeof(Osm.Xml.v0_6.modify)); _ser_delete = new XmlSerializer(typeof(Osm.Xml.v0_6.delete)); XmlReaderSettings settings = new XmlReaderSettings(); settings.CloseInput = true; settings.CheckCharacters = false; settings.IgnoreComments = true; settings.IgnoreProcessingInstructions = true; _reader = XmlReader.Create(_stream, settings); }
public override bool Initialize(ChangeSet changeSet) { if (changeSet.Repository is MercurialRepository) { widget = new MercurialCommitDialogExtensionWidget (); Add (widget); widget.Show (); Show (); widget.Changed += delegate { AllowCommit = widget.CommitterIsAuthor || widget.AuthorName.Length > 0; }; return true; } else return false; }
public override bool Initialize(ChangeSet changeSet) { var repo = changeSet.Repository as TFSRepository; if (repo != null) { widget = new TFSCommitDialogExtensionWidget(); this.Add(widget); widget.Show(); this.Show(); return true; } else return false; }
public override bool Initialize (ChangeSet changeSet) { var repo = changeSet.Repository as GitRepository; if (repo != null) { widget = new GitCommitDialogExtensionWidget (repo); Add (widget); widget.Show (); Show (); widget.Changed += delegate { AllowCommit = widget.CommitterIsAuthor || widget.AuthorName.Length > 0; }; return true; } return false; }
public override bool Submit(ChangeSet changeSet) { var submitResult = false; try { submitResult = base.Submit(changeSet); _dbContext.SaveChanges(); } catch { } return false; }
public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer) { if (dictionary != null) { var changeSet = new ChangeSet { Revision = dictionary.GetValue<int>("revision"), Comments = dictionary.GetValue<string>("comments"), User = dictionary.GetValueAsIdentifiableName("user"), CommittedOn = dictionary.GetValue<DateTime?>("committed_on") }; return changeSet; } return null; }
public IHttpActionResult Put(int id, ChangeSet<TestObject> changeSet) { var item = _repository.Get(id); IHttpActionResult result = Ok(); if (item != null) { changeSet.ApplyChanges(ref item); } else { result = NotFound(); } return result; }
/// <summary> /// When overridden in a derived class, converts the provided dictionary into an object of the specified type. /// </summary> /// <param name="dictionary">An <see cref="T:System.Collections.Generic.IDictionary`2" /> instance of property data stored as name/value pairs.</param> /// <param name="type">The type of the resulting object.</param> /// <param name="serializer">The <see cref="T:System.Web.Script.Serialization.JavaScriptSerializer" /> instance.</param> /// <returns> /// The deserialized object. /// </returns> public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer) { if (dictionary != null) { var changeSet = new ChangeSet { Revision = dictionary.GetValue<int>(RedmineKeys.REVISION), Comments = dictionary.GetValue<string>(RedmineKeys.COMMENTS), User = dictionary.GetValueAsIdentifiableName(RedmineKeys.USER), CommittedOn = dictionary.GetValue<DateTime?>(RedmineKeys.COMMITTED_ON) }; return changeSet; } return null; }
public void changeSetDistinctVisitor_visit() { ChangeSetDistinctVisitor target = new ChangeSetDistinctVisitor(); var entities = new Object[] { new Object() }; var c1 = MockRepository.GenerateStub<IChange>(); c1.Expect( obj => obj.GetChangedEntities() ).Return( entities ); var c2 = MockRepository.GenerateStub<IChange>(); c2.Expect( obj => obj.GetChangedEntities() ).Return( entities ); IChangeSet cSet = new ChangeSet( new IChange[] { c1, c2 } ); var result = target.Visit( cSet ); result.Count.Should().Be.EqualTo( 1 ); result[ entities[ 0 ] ].Should().Be.EqualTo( c2 ); }
internal static ChangeSet ConvertToSimple(Osm.Xml.v0_6.modify modify) { // create change set record. ChangeSet change_set = new ChangeSet(); // create change record. OsmSharp.Osm.Change change = new OsmSharp.Osm.Change(); change.Type = OsmSharp.Osm.ChangeType.Modify; change.OsmGeo = new List<OsmGeo>(); // add all relations to the list. if (modify.relation != null) { foreach (Osm.Xml.v0_6.relation osm_geo in modify.relation) { change.OsmGeo.Add(XmlSimpleConverter.ConvertToSimple(osm_geo)); } } // add all ways to the list. if (modify.way != null) { foreach (Osm.Xml.v0_6.way osm_geo in modify.way) { change.OsmGeo.Add(XmlSimpleConverter.ConvertToSimple(osm_geo)); } } // add all nodes to the list. if (modify.node != null) { foreach (Osm.Xml.v0_6.node osm_geo in modify.node) { change.OsmGeo.Add(XmlSimpleConverter.ConvertToSimple(osm_geo)); } } // add change to changeset change_set.Changes = new List<Change>(); change_set.Changes.Add(change); return change_set; }
/// <summary> /// Throws an exception if there are any change set errors /// </summary> /// <param name="context">The <see cref="OperationContext"/> of the change set</param> /// <param name="changeSet">The change set</param> /// <exception cref="DomainServiceTestHostException">is thrown if there are any change set errors</exception> public static void AssertNoChangeSetErrors(OperationContext context, ChangeSet changeSet) { if (changeSet.HasError) { List<string> errorMessages = new List<string>(); foreach (ChangeSetEntry entry in changeSet.ChangeSetEntries) { if ((entry.ValidationErrors != null) && entry.ValidationErrors.Any()) { errorMessages.Add(ErrorUtility.GetErrorMessageForValidation(entry)); } if ((entry.ConflictMembers != null) && entry.ConflictMembers.Any()) { errorMessages.Add(ErrorUtility.GetErrorMessageForConflicts(entry)); } } ErrorUtility.ReportErrors(context, errorMessages); } }
public void DomainService_CallSubmitDirectly() { DomainServiceDescription description = DomainServiceDescription.GetDescription(typeof(DomainMethod_ValidProvider_MultipleMethods)); List<ChangeSetEntry> changeSetEntries = new List<ChangeSetEntry>(); ChangeSetEntry processCityOperation = new ChangeSetEntry(); processCityOperation.Entity = new City { Name = "Redmond", CountyName = "King", StateName = "WA" }; processCityOperation.DomainOperationEntry = description.GetCustomMethod(typeof(City), "ProcessCity"); processCityOperation.Operation = DomainOperation.Update; processCityOperation.EntityActions = new EntityActionCollection { { "ProcessCity", new object[] { new byte[] { byte.MaxValue, byte.MinValue, 123 } } } }; changeSetEntries.Add(processCityOperation); ChangeSet changeset = new ChangeSet(changeSetEntries); DomainMethod_ValidProvider_MultipleMethods myTestProvider = ServerTestHelper.CreateInitializedDomainService<DomainMethod_ValidProvider_MultipleMethods>(DomainOperationType.Submit); myTestProvider.Submit(changeset); // check that the domain services have invoked the domain method correctly by checking the internal variables set Assert.AreEqual<string>("ProcessCity_", myTestProvider.Invoked); Assert.AreEqual<int>(3, myTestProvider.InputData.Length); Assert.AreEqual<byte>(123, myTestProvider.InputData[2]); }
public override Task<object> ExecuteAsync(HttpControllerContext controllerContext, IDictionary<string, object> arguments) { return TaskHelpers.RunSynchronously<object>(() => { // create a changeset from the entries ChangeSet changeSet = new ChangeSet((IEnumerable<ChangeSetEntry>)arguments[ChangeSetParameterName]); changeSet.SetEntityAssociations(); DataController controller = (DataController)controllerContext.Controller; if (!controller.Submit(changeSet) && controller.ActionContext.Response != null) { // If the submit failed due to an authorization failure, // return the authorization response directly return controller.ActionContext.Response; } // return the entries return controllerContext.Request.CreateResponse<ChangeSetEntry[]>(HttpStatusCode.OK, changeSet.ChangeSetEntries.ToArray()); }); }
public ValueListNodeInputViewModel() { MaxConnections = Int32.MaxValue; ConnectionValidator = pending => new ConnectionValidationResult( pending.Output is ValueNodeOutputViewModel <T> || pending.Output is ValueNodeOutputViewModel <IObservableList <T> >, null ); var valuesFromSingles = Connections.Connect(c => c.Output is ValueNodeOutputViewModel <T>) .Transform(c => (ValueNodeOutputViewModel <T>)c.Output) //Note: this line used to be //.AutoRefresh(output => output.CurrentValue) //which ignored changes where CurrentValue didn't change. //This caused problems when the value object isn't replaced, but one of its properties changes. .AutoRefreshOnObservable(output => output.Value) // Null values are not allowed, so filter before transform .Filter(output => output.CurrentValue != null) .Transform(output => output.CurrentValue, true) // Any 'replace' changes that don't change the value should be refresh changes // This prevents issues where a value is updated, but it doesn't propagate through the network // because the connections didn't change. .Select(changes => { if (changes.TotalChanges == changes.Replaced + changes.Refreshes) { bool allRefresh = true; var newChanges = new ChangeSet <T>(); foreach (var change in changes) { if (change.Reason == ListChangeReason.Replace) { if (change.Type == ChangeType.Item) { if (change.Item.Previous != change.Item.Current) { allRefresh = false; break; } newChanges.Add(new Change <T>(ListChangeReason.Refresh, change.Item.Current, change.Item.Previous, change.Item.CurrentIndex, change.Item.PreviousIndex)); } else { throw new Exception("Does this ever occur?"); } } else { newChanges.Add(change); } } if (allRefresh) { return(newChanges); } } return(changes); }); var valuesFromLists = Connections.Connect(c => c.Output is ValueNodeOutputViewModel <IObservableList <T> >) // Grab list of values from output, using switch to handle when the list object is replaced .Transform(c => ((ValueNodeOutputViewModel <IObservableList <T> >)c.Output).Value.Switch()) // Materialize this changeset stream into a list (needed to make sure the next step is done dynamically) .AsObservableList() // Take the union of all values from all lists. This is done dynamically, so adding/removing new lists works as expected. .Or(); Values = valuesFromSingles.Or(valuesFromLists).AsObservableList(); }
/// <summary> /// Invokes the insert operation for the specified entity and returns the <see cref="ChangeSet"/> /// and whether the operation completed successfully /// </summary> /// <typeparam name="TEntity">The entity type</typeparam> /// <param name="entity">The entity to insert</param> /// <param name="changeSet">The operation <see cref="ChangeSet"/></param> /// <returns>Whether the operation completed without error</returns> public bool TryInsert <TEntity>(TEntity entity, out ChangeSet changeSet) where TEntity : class { IList <ValidationResult> validationErrors; return(this.TrySubmitCore(DomainOperation.Insert, /* submitOperation */ null, entity, /* original */ null, out validationErrors, out changeSet)); }
/// <summary> /// Invokes the update operation for the specified entity and returns the <see cref="ChangeSet"/> /// and whether the operation completed successfully /// </summary> /// <remarks> /// This method should be used for custom-named Update operations /// </remarks> /// <typeparam name="TEntity">The entity type</typeparam> /// <param name="updateOperation">The <see cref="Expression"/> identifying the update operation to invoke</param> /// <param name="original">The original version of the entity. This parameter can be <c>null</c>.</param> /// <param name="changeSet">The operation <see cref="ChangeSet"/></param> /// <returns>Whether the operation completed without error</returns> public bool TryUpdate <TEntity>(Expression <Action <TDomainService> > updateOperation, TEntity original, out ChangeSet changeSet) where TEntity : class { IList <ValidationResult> validationErrors; return(this.TrySubmitCore <TEntity>(DomainOperation.Update, updateOperation, /* entity */ null, original, out validationErrors, out changeSet)); }
/// <summary> /// Invokes the delete operation for the specified entity and returns the <see cref="ChangeSet"/> /// and whether the operation completed successfully /// </summary> /// <typeparam name="TEntity">The entity type</typeparam> /// <param name="entity">The entity to delete</param> /// <param name="original">The original version of the entity. This parameter can be <c>null</c>.</param> /// <param name="changeSet">The operation <see cref="ChangeSet"/></param> /// <returns>Whether the operation completed without error</returns> public bool TryDelete <TEntity>(TEntity entity, TEntity original, out ChangeSet changeSet) where TEntity : class { IList <ValidationResult> validationErrors; return(this.TrySubmitCore <TEntity>(DomainOperation.Delete, /* submitOperation */ null, entity, original, out validationErrors, out changeSet)); }
/// <summary> /// Invokes all <see cref="ChangeSetEntry"/> in the <see cref="ChangeSet"/>. /// </summary> /// <returns><c>true</c> if the Submit was performed without any errors; otherwise <c>false</c></returns> /// <remarks>This method is intended to allow testing Submit with multiple entities at once. /// To test CUD operations for single entities have a look at <see cref="Insert{TEntity}(TEntity)"/>, /// <see cref="Update{TEntity}(TEntity, TEntity)"/> and <see cref="Delete{TEntity}(TEntity, TEntity)"/> /// </remarks> /// <param name="changeSet">The <see cref="ChangeSet"/> to execute</param> /// <param name="validationErrors">The validation errors that occurred</param> /// <exception cref="DomainServiceTestHostException">is thrown if there are any <see cref="ChangeSet"/> errors</exception> public bool TrySubmit(ChangeSet changeSet, out IList <ValidationResult> validationErrors) { OperationContext context = this.CreateOperationContext(DomainOperationType.Submit); return(TrySubmitChangeSetCore(context, changeSet, out validationErrors)); }
/// <summary> /// Invokes an operation according to the specified <paramref name="operationType"/> and entity and returns /// the validation errors, the change set, and whether the operation completed successfully /// </summary> /// <typeparam name="TEntity">The entity type</typeparam> /// <param name="operationType">The type of operation to invoke</param> /// <param name="submitOperation"> /// The <see cref="Expression"/> identifying the operation to invoke. This parameter can be <c>null</c> /// as long as <paramref name="entity"/> is not. /// </param> /// <param name="entity"> /// The entity to pass to the operation. This parameter can be <c>null</c> as long as /// <paramref name="submitOperation"/> is not. /// </param> /// <param name="original">The original version of the entity. This parameter can be <c>null</c>.</param> /// <param name="validationResults">The validation errors that occurred</param> /// <param name="changeSet">The change set</param> private bool TrySubmitCore <TEntity>(DomainOperation operationType, Expression submitOperation, TEntity entity, TEntity original, out IList <ValidationResult> validationResults, out ChangeSet changeSet) where TEntity : class { OperationContext context = this.CreateOperationContext(DomainOperationType.Submit); ChangeSetEntry changeSetEntry; if (operationType == DomainOperation.Update) { if (submitOperation != null) { changeSetEntry = Utility.GetCustomUpdateChangeSetEntry(context, submitOperation, original); } else { changeSetEntry = Utility.GetChangeSetEntry(context, entity, original, operationType); changeSetEntry.HasMemberChanges = true; } } else { changeSetEntry = Utility.GetChangeSetEntry(context, entity, original, operationType); } changeSet = Utility.CreateChangeSet(changeSetEntry); return(TrySubmitChangeSetCore(context, changeSet, out validationResults)); }
private async void OnBoardChanged(object sender, ChangeSet changes) { board = board.WithChanges(changes); await InvokeAsync(StateHasChanged); }
public async Task <HttpResponseMessage> Deploy(string id = null) { JObject result = GetJsonContent(); // Just block here to read the json payload from the body using (_tracer.Step("DeploymentService.Deploy(id)")) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); await _deploymentLock.LockHttpOperationAsync(async() => { try { if (_autoSwapHandler.IsAutoSwapOngoing()) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.Conflict, Resources.Error_AutoSwapDeploymentOngoing)); } DeployResult deployResult; if (TryParseDeployResult(id, result, out deployResult)) { using (_tracer.Step("DeploymentService.Create(id)")) { CreateDeployment(deployResult, result.Value <string>("details")); // e.g if final url is "https://kudutry.scm.azurewebsites.net/api/deployments/ef52ec67fc9574e726955a9cbaf7bcba791e4e95/log" // deploymentUri should be "https://kudutry.scm.azurewebsites.net/api/deployments/ef52ec67fc9574e726955a9cbaf7bcba791e4e95" Uri deploymentUri = UriHelper.MakeRelative(UriHelper.GetBaseUri(Request), Request.RequestUri.AbsolutePath); deployResult.Url = deploymentUri; deployResult.LogUrl = UriHelper.MakeRelative(deploymentUri, "log"); response = Request.CreateResponse(HttpStatusCode.OK, ArmUtils.AddEnvelopeOnArmRequest(deployResult, Request)); return; } } bool clean = false; bool needFileUpdate = true; if (result != null) { clean = result.Value <bool>("clean"); JToken needFileUpdateToken; if (result.TryGetValue("needFileUpdate", out needFileUpdateToken)) { needFileUpdate = needFileUpdateToken.Value <bool>(); } } string username = null; AuthUtility.TryExtractBasicAuthUser(Request, out username); IRepository repository = _repositoryFactory.GetRepository(); if (repository == null) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, Resources.Error_RepositoryNotFound)); } ChangeSet changeSet = null; if (!String.IsNullOrEmpty(id)) { changeSet = repository.GetChangeSet(id); if (changeSet == null) { string message = String.Format(CultureInfo.CurrentCulture, Resources.Error_DeploymentNotFound, id); throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message)); } } await _deploymentManager.DeployAsync(repository, changeSet, username, clean, needFileUpdate); // auto-swap if (_autoSwapHandler.IsAutoSwapEnabled()) { if (changeSet == null) { var targetBranch = _settings.GetBranch(); changeSet = repository.GetChangeSet(targetBranch); } IDeploymentStatusFile statusFile = _status.Open(changeSet.Id); if (statusFile != null && statusFile.Status == DeployStatus.Success) { await _autoSwapHandler.HandleAutoSwap(changeSet.Id, _deploymentManager.GetLogger(changeSet.Id), _tracer); } } } catch (FileNotFoundException ex) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } }, "Performing deployment"); return(response); } }
public virtual async Task <bool> Submit(ChangeSet changes, Action <DbContext, ChangeSet> doInStart = null, Action <DbContext, ChangeSet> doBeforePersist = null, Action <DbContext, ChangeSet> doInEnd = null) { return(await DataService.Submit(changes, doInStart, doBeforePersist, doInEnd)); }
/// <summary> /// Invokes all <see cref="ChangeSetEntry"/> in the <see cref="ChangeSet"/>. /// </summary> /// <remarks>This method is intended to allow testing Submit with multiple entities at once. /// To test CUD operations for single entities have a look at <see cref="Insert{TEntity}(TEntity)"/>, /// <see cref="Update{TEntity}(TEntity, TEntity)"/> and <see cref="Delete{TEntity}(TEntity, TEntity)"/> /// </remarks> /// <param name="changeSet">The <see cref="ChangeSet"/> to execute</param> /// <exception cref="DomainServiceTestHostException">is thrown if there are any <see cref="ChangeSet"/> errors</exception> public void Submit(ChangeSet changeSet) { OperationContext context = this.CreateOperationContext(DomainOperationType.Submit); SubmitChangeSetCore(context, changeSet); }