private static void ExecAction(object obj) { ICommand command = null; switch (obj) { case InitArgs args: var settings = new ProjectSettings(args.ProjectName, args.RootDirectory, args.IssueUrl); command = new InitCommand(settings); break; case AddArgs args: var changeLogEntry = new ChangeLogEntry(args.Description, args.Author, args.IssueId, args.Type); command = new AddCommand(changeLogEntry); break; case MergeArgs _: command = new MergeCommand(); break; } if (command != null) { command.Execute(); } }
public virtual async Task UpdateSendResults(List <SignalEvent <long> > items) { List <SignalEventLong> mappedList = items .Select(_mapper.Map <SignalEventLong>) .ToList(); string tvpName = TableValuedParameters.GetFullTVPName(_connectionSettings.Schema, TableValuedParameters.EVENT_UPDATE_TYPE); using (Repository repository = new Repository(_dbContextFactory.GetDbContext())) { MergeCommand <SignalEventLong> update = repository.MergeTVP(mappedList, tvpName); update.Source.IncludeProperty(p => p.SignalEventId) .IncludeProperty(p => p.FailedAttempts) .IncludeProperty(p => p.EventSettingsId) .IncludeProperty(p => p.SubscriberIdRangeFrom) .IncludeProperty(p => p.SubscriberIdRangeTo) .IncludeProperty(p => p.SubscriberIdFromDeliveryTypesHandledSerialized); update.Compare.IncludeProperty(p => p.SignalEventId); update.UpdateMatched .IncludeProperty(p => p.FailedAttempts) .IncludeProperty(p => p.EventSettingsId) .IncludeProperty(p => p.SubscriberIdRangeFrom) .IncludeProperty(p => p.SubscriberIdRangeTo) .IncludeProperty(p => p.SubscriberIdFromDeliveryTypesHandledSerialized); int changes = await update.ExecuteAsync(MergeType.Update) .ConfigureAwait(false); } }
public void then_merge_output_no_ids() { var entities = new List <SampleEntity>(); for (int i = 0; i < 15; i++) { entities.Add(new SampleEntity { GuidNullableProperty = null, DateProperty = DateTime.UtcNow, GuidProperty = Guid.NewGuid() }); } MergeCommand <SampleEntity> command = SUT.Merge <SampleEntity>(entities); command.Compare.IncludeProperty(x => x.Id); command.Output.IncludeProperty(x => x.Id); int changes = command.Execute(MergeType.DeleteMatched); //Assert changes.ShouldEqual(0); entities.ForEach( (entity) => entity.Id.ShouldEqual(0)); }
/// <summary> /// Add a input file. /// </summary> /// <param name="file">The path of the file</param> public async Task AddInputFile(string file) { switch (OutOfProcessHelper.TestSourceFile(file)) { //File is corrupt pdf. case OutOfProcessHelper.SourceTestResult.Unreadable: //Tell the user the pdf is corrupt. Application.Current.Dispatcher.BeginInvoke(new Action(() => ((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("The file " + Path.GetFileName(file) + " could not be opened as a PDF or image", "Some thing went wrong when opening " + Path.GetFileName(file)))); break; //File is a valid pdf. case OutOfProcessHelper.SourceTestResult.Ok: //Add the pdf to the ListBox. Application.Current.Dispatcher.Invoke(new Action(() => Files.Add(new PDFItem(file, null)))); break; //File is a image (maybe not valid!). case OutOfProcessHelper.SourceTestResult.Image: break; } //Update Commands Application.Current.Dispatcher.Invoke(() => MergeCommand.RaiseCanExecuteChanged()); MoveUpCommand.RaiseCanExecuteChanged(); MoveDownCommand.RaiseCanExecuteChanged(); Application.Current.Dispatcher.Invoke(() => RemoveCommand.RaiseCanExecuteChanged()); }
protected override void When() { MergeCommand <SampleEntity> command = SUT.Merge(InsertItems); command.Compare.IncludeProperty(x => x.Id); _changes = command.Execute(MergeType.Insert); }
static void Main(string[] args) { var name = Assembly.GetCallingAssembly().GetName().Name; var suite = new CommandSet(name) { $"usage: {name} COMMAND [OPTIONS]+", new Command("switch", "switch dll reference to project reference in a solution") { Run = args2 => SwitchCommand.Run(args2.ToArray()) }, new Command("merge", "merge solution files to a single solution") { Run = args2 => MergeCommand.Run(args2.ToArray()) }, new Command("remove-imports", "remove imports from project files") { Run = args2 => RemoveImportCommand.Run(args2.ToArray()) }, new Command("remove-projects", "remove projects from solution files") { Run = args2 => RemoveProjectsCommand.Run(args2.ToArray()) } }; suite.Run(args); }
public static void ReportShelfResult(MercurialProgressMonitor monitor, MergeCommand result) { throw new NotImplementedException(); /* * if (result.GetMergeStatus () == NGit.Api.MergeStatus.FAILED) { * string msg = GettextCatalog.GetString ("Stash operation failed."); * DispatchService.GuiDispatch (delegate { * IdeApp.Workbench.StatusBar.ShowWarning (msg); * }); * string txt = msg + "\n\n" + GetMergeResultErrorDetail (result); * monitor.ReportError (txt, null); * } * else if (result.GetMergeStatus () == NGit.Api.MergeStatus.NOT_SUPPORTED) { * string msg = GettextCatalog.GetString ("Operation not supported"); * monitor.ReportError (msg, null); * DispatchService.GuiDispatch (delegate { * IdeApp.Workbench.StatusBar.ShowWarning (msg); * }); * } * else if (result.GetMergeStatus () == NGit.Api.MergeStatus.CONFLICTING) { * string msg = GettextCatalog.GetString ("Stash applied with conflicts"); * DispatchService.GuiDispatch (delegate { * IdeApp.Workbench.StatusBar.ShowWarning (msg); * }); * } * else { * string msg = GettextCatalog.GetString ("Stash successfully applied"); * DispatchService.GuiDispatch (delegate { * IdeApp.Workbench.StatusBar.ShowMessage (msg); * }); * } */ }
public virtual async Task Update(List <StoredNotification <long> > items) { List <StoredNotificationLong> mappedList = items .Select(_mapper.Map <StoredNotificationLong>) .ToList(); using (Repository repository = new Repository(_dbContextFactory.GetDbContext())) { string tvpName = TableValuedParameters.GetFullTVPName(_connectionSettings.Schema , TableValuedParameters.STORED_NOTIFICATION_TYPE); MergeCommand <StoredNotificationLong> merge = repository.MergeTVP(mappedList, tvpName); merge.Source .IncludeProperty(x => x.StoredNotificationId) .IncludeProperty(x => x.SubscriberId) .IncludeProperty(x => x.CategoryId) .IncludeProperty(x => x.TopicId) .IncludeProperty(x => x.CreateDateUtc) .IncludeProperty(x => x.MessageSubject) .IncludeProperty(x => x.MessageBody); merge.Compare .IncludeProperty(p => p.StoredNotificationId); merge.UpdateMatched .ExcludeProperty(p => p.StoredNotificationId); int changes = await merge.ExecuteAsync(MergeType.Update).ConfigureAwait(false); } }
private void FilesCollectionChanged( object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { RaisePropertyChanged(nameof(FileListEmpty)); RaisePropertyChanged(nameof(MergeCommandCaption)); MergeCommand?.RaiseCanExecuteChanged(); }
public void Index() { var m = new MergeCommand("core0", new MergeCommand.IndexDir("/path/to/index1"), new MergeCommand.IndexDir("/path/to/index2")); var parameters = m.GetParameters().ToList(); CollectionAssert.Contains(parameters, KV.Create("action", "mergeindexes")); CollectionAssert.Contains(parameters, KV.Create("indexDir", "/path/to/index1")); CollectionAssert.Contains(parameters, KV.Create("indexDir", "/path/to/index2")); CollectionAssert.Contains(parameters, KV.Create("core", "core0")); }
public void Core() { var m = new MergeCommand("core0", new MergeCommand.SrcCore("core1"), new MergeCommand.SrcCore("core2")); var parameters = m.GetParameters().ToList(); CollectionAssert.Contains(parameters, KV.Create("action", "mergeindexes")); CollectionAssert.Contains(parameters, KV.Create("srcCore", "core1")); CollectionAssert.Contains(parameters, KV.Create("srcCore", "core2")); CollectionAssert.Contains(parameters, KV.Create("core", "core0")); }
public override void Loaded(object sender, SectionLoadedEventArgs e) { base.Loaded(sender, e); //manually set to false because apparently HideBusy will set isBusy on false much later... IsBusy = false; MergeCommand.RaiseCanExecuteChanged(); FetchChangesetsCommand.RaiseCanExecuteChanged(); }
private async Task <(int exitCode, IConsole console)> RunCommand(params string[] args) { var command = new MergeCommand(); var console = new TestConsole(); var exitCode = await command.InvokeAsync(args, console); return(exitCode, console); }
protected override void When() { MergeCommand <SampleEntity> command = SUT.Merge(_insertedItems); command.Compare.IncludeProperty(x => x.Id); command.Output .SetExcludeAllByDefault(true) .SetExcludeDbGeneratedByDefault(ExcludeOptions.Exclude); _changes = command.Execute(MergeType.Insert); }
public virtual async Task UpsertIsEnabled(List <SubscriberTopicSettingsLong> items) { List <long> disabledTopics = items .Where(x => x.IsEnabled == false) .Select(x => x.SubscriberTopicSettingsId) .ToList(); List <SubscriberTopicSettingsLong> enabledTopics = items .Where(x => x.IsEnabled) .ToList(); using (Repository repository = new Repository(_dbContextFactory.GetDbContext())) using (IDbContextTransaction ts = repository.Context.Database.BeginTransaction()) { SqlTransaction sqlTransaction = (SqlTransaction)ts.GetDbTransaction(); if (disabledTopics.Count > 0) { int changes = await repository.DeleteManyAsync <SubscriberTopicSettingsLong>( x => disabledTopics.Contains(x.SubscriberTopicSettingsId)) .ConfigureAwait(false); } if (enabledTopics.Count > 0) { string tvpName = TableValuedParameters.GetFullTVPName(_connectionSettings.Schema , TableValuedParameters.SUBSCRIBER_TOPIC_SETTINGS_TYPE); MergeCommand <SubscriberTopicSettingsLong> merge = repository.MergeTVP(enabledTopics, tvpName, sqlTransaction); merge.Source .IncludeProperty(p => p.TopicId) .IncludeProperty(p => p.CategoryId) .IncludeProperty(p => p.DeliveryType) .IncludeProperty(p => p.SubscriberId) .IncludeProperty(p => p.AddDateUtc) .IncludeProperty(p => p.IsEnabled); merge.Compare .IncludeProperty(p => p.SubscriberId) .IncludeProperty(p => p.TopicId) .IncludeProperty(p => p.CategoryId) .IncludeProperty(p => p.DeliveryType); merge.UpdateMatched .IncludeProperty(p => p.IsEnabled); merge.Insert .IncludeProperty(p => p.TopicId) .IncludeProperty(p => p.CategoryId) .IncludeProperty(p => p.DeliveryType) .IncludeProperty(p => p.SubscriberId) .IncludeProperty(p => p.AddDateUtc) .IncludeProperty(p => p.IsEnabled) .IncludeDefaultValue(p => p.SendCount) .IncludeDefaultValue(p => p.IsDeleted); int changes = await merge.ExecuteAsync(MergeType.Upsert).ConfigureAwait(false); } ts.Commit(); } }
protected override void When() { using (DbContextTransaction ts = SampleDatabase.Database.BeginTransaction()) { SqlTransaction transaction = (SqlTransaction)ts.UnderlyingTransaction; MergeCommand <SampleEntity> command = SUT.Merge(_insertedItems, transaction); command.Compare.IncludeProperty(x => x.Id); _changes = command.Execute(MergeType.Insert); } }
//methods public virtual async Task Insert <TEntity>(List <TEntity> entities) where TEntity : class { //will set ids generated by database on entities using (DbContext dbContext = _dbContextFactory()) { var merge = new MergeCommand <TEntity>(dbContext, entities); merge.Output.SetExcludeAllByDefault(true) .SetExcludeDbGeneratedByDefault(ExcludeOptions.Include); int insertedCount = await merge.ExecuteAsync(MergeType.Insert) .ConfigureAwait(false); } }
public virtual async Task UpsertIsEnabled(List <SubscriberCategorySettingsLong> items) { List <long> disabledCategories = items .Where(x => x.IsEnabled == false) .Select(x => x.SubscriberCategorySettingsId) .ToList(); List <SubscriberCategorySettingsLong> enabledCategories = items .Where(x => x.IsEnabled) .ToList(); using (Repository repository = new Repository(_dbContextFactory.GetDbContext())) { if (disabledCategories.Count > 0) { int changes = await repository.DeleteManyAsync <SubscriberCategorySettingsLong>( x => disabledCategories.Contains(x.SubscriberCategorySettingsId)) .ConfigureAwait(false); } if (enabledCategories.Count > 0) { string tvpName = TableValuedParameters.GetFullTVPName(_connectionSettings.Schema , TableValuedParameters.SUBSCRIBER_CATEGORY_SETTINGS_TYPE); MergeCommand <SubscriberCategorySettingsLong> merge = repository.MergeTVP(enabledCategories, tvpName); merge.Source .IncludeProperty(p => p.SubscriberId) .IncludeProperty(p => p.DeliveryType) .IncludeProperty(p => p.CategoryId) .IncludeProperty(p => p.LastSendDateUtc) .IncludeProperty(p => p.SendCount) .IncludeProperty(p => p.IsEnabled); merge.Compare .IncludeProperty(p => p.SubscriberId) .IncludeProperty(p => p.CategoryId) .IncludeProperty(p => p.DeliveryType); merge.UpdateMatched .IncludeProperty(p => p.IsEnabled); merge.Insert .IncludeProperty(p => p.SubscriberId) .IncludeProperty(p => p.DeliveryType) .IncludeProperty(p => p.CategoryId) .IncludeProperty(p => p.LastSendDateUtc) .IncludeProperty(p => p.SendCount) .IncludeProperty(p => p.IsEnabled); int changes = await merge.ExecuteAsync(MergeType.Upsert) .ConfigureAwait(false); } } }
protected override void When() { using (DbContextTransaction ts = SampleDatabase.Database.BeginTransaction()) { SqlTransaction transaction = (SqlTransaction)ts.UnderlyingTransaction; MergeCommand <SampleEntity> command = SUT.Merge(_insertedItems, transaction); command.Compare.IncludeProperty(x => x.Id); command.Output .SetExcludeAllByDefault(true) .SetExcludeDbGeneratedByDefault(ExcludeOptions.Exclude); _changes = command.Execute(MergeType.Insert); } }
public virtual async Task UpdateTemplates(List <DispatchTemplate <long> > items, DbContext context, SqlTransaction transaction) { List <DispatchTemplateLong> mappedItems = items .Select(_mapper.Map <DispatchTemplateLong>) .ToList(); MergeCommand <DispatchTemplateLong> merge = new MergeCommand <DispatchTemplateLong>(context, mappedItems, transaction); merge.Compare .IncludeProperty(p => p.DispatchTemplateId); merge.UpdateMatched .ExcludeProperty(x => x.DispatchTemplateId); int changes = await merge.ExecuteAsync(MergeType.Update).ConfigureAwait(false); }
protected override void When() { using (var scope = new TransactionScope()) { MergeCommand <SampleEntity> command1 = SUT.Merge(InsertItems); command1.UseInnerTransactionForBatches = false; _changes1 = command1.Execute(MergeType.Insert); MergeCommand <SampleEntity> command2 = SUT.Merge(InsertItems); command2.UseInnerTransactionForBatches = false; _changes2 = command2.Execute(MergeType.Insert); scope.Complete(); } }
//update public virtual async Task Update(List <DispatchTemplate <long> > items) { List <DispatchTemplateLong> mappedItems = items .Select(_mapper.Map <DispatchTemplateLong>) .ToList(); using (Repository repository = new Repository(_dbContextFactory.GetDbContext())) { MergeCommand <DispatchTemplateLong> merge = repository.Merge(mappedItems); merge.Compare .IncludeProperty(p => p.DispatchTemplateId); merge.UpdateMatched .ExcludeProperty(x => x.DispatchTemplateId); int changes = await merge.ExecuteAsync(MergeType.Update).ConfigureAwait(false); } }
public virtual async Task Upsert(SubscriberTopicSettingsLong item, bool updateExisting) { using (Repository repository = new Repository(_dbContextFactory.GetDbContext())) { MergeCommand <SubscriberTopicSettingsLong> merge = repository.Merge(item); merge.Compare.IncludeProperty(p => p.SubscriberId) .IncludeProperty(p => p.CategoryId) .IncludeProperty(p => p.TopicId); if (updateExisting) { merge.UpdateMatched.IncludeProperty(p => p.IsEnabled) .IncludeProperty(p => p.IsDeleted); } int changes = await merge.ExecuteAsync(MergeType.Upsert) .ConfigureAwait(false); } }
//update public virtual async Task UpdateIsEnabled(List <SubscriberTopicSettingsLong> items) { using (Repository repository = new Repository(_dbContextFactory.GetDbContext())) { string tvpName = TableValuedParameters.GetFullTVPName(_connectionSettings.Schema, TableValuedParameters.SUBSCRIBER_TOPIC_SETTINGS_TYPE_IS_ENABLED); MergeCommand <SubscriberTopicSettingsLong> merge = repository.MergeTVP(items, tvpName); merge.Source .IncludeProperty(p => p.SubscriberTopicSettingsId) .IncludeProperty(p => p.IsEnabled); merge.Compare .IncludeProperty(p => p.SubscriberTopicSettingsId); merge.UpdateMatched .IncludeProperty(p => p.IsEnabled); int changes = await merge.ExecuteAsync(MergeType.Update) .ConfigureAwait(false); } }
protected override void When() { for (int i = 0; i < 15; i++) { _insertedItems[i].DateProperty = new DateTime(2005, 2, 2, 2, 2, i); } MergeCommand <SampleEntity> command = SUT.Merge(_insertedItems); command.Source .IncludeProperty(x => x.Id) .IncludeProperty(x => x.DateProperty); command.Compare .IncludeProperty(x => x.Id); command.UpdateMatched .IncludeProperty(x => x.DateProperty); _changes = command.Execute(MergeType.Update); }
private async Task FetchChangesetsAsync() { await _setBusyWhileExecutingAsync(async() => { Changesets.Clear(); var changesets = await _teamService.GetChangesetsAsync(SelectedSourceBranch, SelectedTargetBranch); Changesets = new ObservableCollection <Changeset>(changesets); if (_configManager.GetValue <bool>(ConfigKeys.ENABLE_AUTO_SELECT_ALL_CHANGESETS)) { SelectedChangesets.AddRange(Changesets.Except(SelectedChangesets)); RaisePropertyChanged(nameof(SelectedChangesets)); } }); MergeCommand.RaiseCanExecuteChanged(); }
protected virtual async Task InsertTemplates(List <DispatchTemplate <long> > items , DbContext context, SqlTransaction underlyingTransaction) { List <DispatchTemplateLong> mappedList = items .Select(_mapper.Map <DispatchTemplateLong>) .ToList(); var mergeCommand = new MergeCommand <DispatchTemplateLong>(context, mappedList, underlyingTransaction); mergeCommand.Insert .ExcludeProperty(x => x.DispatchTemplateId); mergeCommand.Output .IncludeProperty(x => x.DispatchTemplateId); int changes = await mergeCommand.ExecuteAsync(MergeType.Insert).ConfigureAwait(false); for (int i = 0; i < mappedList.Count; i++) { items[i].DispatchTemplateId = mappedList[i].DispatchTemplateId; } }
private void button10_Click(object sender, EventArgs e) { bool b = isSelect(); if (b) { //执行命令 ICommand mCmd = new MergeCommand(); mCmd.OnCreate(axMapControl1.Object); (mCmd as MergeCommand).mLayer = layer; (mCmd as MergeCommand).pMapControl = axMapControl1; axMapControl1.CurrentTool = mCmd as ITool; } else { XtraMessageBox.Show("请选择要素", "提示信息", MessageBoxButtons.OK); return; } }
//insert public virtual async Task Insert(List <EventSettings <long> > items) { List <EventSettingsLong> mappedList = items .Select(_mapper.Map <EventSettingsLong>) .ToList(); using (Repository repository = new Repository(_dbContextFactory.GetDbContext())) using (IDbContextTransaction ts = repository.Context.Database.BeginTransaction()) { SqlTransaction underlyingTransaction = (SqlTransaction)ts.GetDbTransaction(); MergeCommand <EventSettingsLong> mergeCommand = repository.Merge(mappedList, underlyingTransaction); mergeCommand.Insert .ExcludeProperty(x => x.EventSettingsId) .ExcludeProperty(x => x.TemplatesNavigation); mergeCommand.Output .IncludeProperty(x => x.EventSettingsId); int changes = await mergeCommand.ExecuteAsync(MergeType.Insert).ConfigureAwait(false); for (int i = 0; i < mappedList.Count; i++) { EventSettingsLong mappedItem = mappedList[i]; items[i].EventSettingsId = mappedItem.EventSettingsId; if (mappedItem.Templates != null) { mappedItem.Templates.ForEach( x => x.EventSettingsId = mappedItem.EventSettingsId); } } List <DispatchTemplate <long> > templates = items .SelectMany(x => x.Templates) .ToList(); await InsertTemplates(templates, repository.Context, underlyingTransaction) .ConfigureAwait(false); ts.Commit(); } }
static void Merge(string[] args) { string dir = null; if (Array.IndexOf(args, "--dir") > 0) { dir = args[Array.IndexOf(args, "--dir") + 1]; } if (dir != null) { using (var merge = new MergeCommand(dir)) { var result = merge.Commit(); if (result == -1) { Console.Write("nothing to merge or truncate in dir {0}", dir); } } } }
public static void ReportShelfResult(MercurialProgressMonitor monitor, MergeCommand result) { throw new NotImplementedException (); /* if (result.GetMergeStatus () == NGit.Api.MergeStatus.FAILED) { string msg = GettextCatalog.GetString ("Stash operation failed."); DispatchService.GuiDispatch (delegate { IdeApp.Workbench.StatusBar.ShowWarning (msg); }); string txt = msg + "\n\n" + GetMergeResultErrorDetail (result); monitor.ReportError (txt, null); } else if (result.GetMergeStatus () == NGit.Api.MergeStatus.NOT_SUPPORTED) { string msg = GettextCatalog.GetString ("Operation not supported"); monitor.ReportError (msg, null); DispatchService.GuiDispatch (delegate { IdeApp.Workbench.StatusBar.ShowWarning (msg); }); } else if (result.GetMergeStatus () == NGit.Api.MergeStatus.CONFLICTING) { string msg = GettextCatalog.GetString ("Stash applied with conflicts"); DispatchService.GuiDispatch (delegate { IdeApp.Workbench.StatusBar.ShowWarning (msg); }); } else { string msg = GettextCatalog.GetString ("Stash successfully applied"); DispatchService.GuiDispatch (delegate { IdeApp.Workbench.StatusBar.ShowMessage (msg); }); } */ }