예제 #1
0
        private void btnRefresh_Click(object sender, RoutedEventArgs e)
        {
            if (Service != null)
            {
                BackgroundWorker worker = new BackgroundWorker();
                loadingAnimation.Visibility = Visibility.Visible;

                worker.DoWork += delegate(object s, DoWorkEventArgs args)
                {
                    object[] data = args.Argument as object[];

                    IReportingService reportingService = ObjectLocator.GetInstance <IReportingService>();

                    List <ActivationLog>     activationLogs    = reportingService.GetAllServiceActivationLogs((Service)data[0]);
                    List <LicenseActivation> licenseActivation = reportingService.GetAllServiceLicenseActivations((Service)data[0]);

                    object[] returnData = new object[2];
                    returnData[0] = activationLogs;
                    returnData[1] = licenseActivation;

                    args.Result = returnData;
                };

                worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
                {
                    object[] result = args.Result as object[];

                    gridActivationLogs.ItemsSource      = (List <ActivationLog>)result[0];
                    gridLicenseActiviations.ItemsSource = (List <LicenseActivation>)result[1];

                    loadingAnimation.Visibility = Visibility.Collapsed;
                };

                worker.RunWorkerAsync(new object[]
                {
                    Service
                });
            }
            else
            {
                MessageBox.Show("You need to select a service before refreshing the data.");
            }
        }