调试

时间:2017-09-12 09:19:41

标签: c# asp.net api asp.net-web-api web

我有一个类似下面代码的事件处理程序:

viewer.LocalReport.SubreportProcessing += new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(LocalReport_SubreportProcessing);

此方法作为上述事件处理程序的参数:

private static void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e) {

        DateTime movementDate = Convert.ToDateTime(e.Parameters[0].Values[0]);

        TourTransactionsController controller = new TourTransactionsController();

        var movement = controller.Movements();

        List<Movement> movementList = new List<Movement>();
        movementList.Add(new Movement {
            Destination = "TEST",
            MovementDescription = "TEST",
            DateTime = Convert.ToDateTime("2017-09-25")
        });

        e.DataSources.Clear();

        e.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource() {
            Name = "DSMovements",
            Value = movementList
        });

        //throw new NotImplementedException();
    }

这两种方法都是用 WEB API Controller 编写的。事件处理程序在调试时正在按下,但是在我按下F11(步入)后调试LocalReport_SubreportProcessing方法没有按下时。为什么LocalReport_SubreportProcessing方法无法击中?

非常感谢任何帮助或回答。

1 个答案:

答案 0 :(得分:0)

当您注册/ module.config.php namespace Application; return [ //... // myroute1 will route to IndexController fooAction if the route is matching '/index/foo' but regardless of request method 'myroute1' => [ 'type' => Zend\Router\Http\Literal::class, 'options' => [ 'route' => '/index/foo', 'defaults' => [ 'controller' => Controller\IndexController::class, 'action' => 'foo', ], ], ], // myroute2 will route to IndexController fooAction if the route is request method is GET but regardless of requested route 'myroute2' => [ 'type' => Zend\Router\Http\Method::class, 'options' => [ 'verb' => 'get', 'defaults' => [ 'controller' => Controller\IndexController::class, 'action' => 'foo', ], ], ], //... ]; 时,系统不会调用事件。

当拥有的类调用它时会调用事件。

add

当事件触发时,将调用您的处理程序。

注册+=public class EventTest { void SomeOperation() { //Do something } public void Run() { SomeOperation(); RunFinished?.Invoke(this, EventArgs.Empty); //Invoke the event, indicating that something has happened or finished } //The event itself public event EventHandler RunFinished; } public class EventSubscriber { EventTest _ET = new EventTest(); public EventSubscriber() { _ET.RunFinished += ETRunFinished; //Register my method, called when the event occurs (is invoked) } public void DoSomething() { _ET.Run(); Console.WriteLine("Something completed."); } void ETRunFinished(object sender, EventArgs e) { Console.WriteLine("My event handler was executed."); } } 取消注册(添加/删除)时,不会调用它们。

如需更多detailed tutorial,请参阅MSDN。