/// <summary> /// handler for ok button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void okBtn_Click(object sender, RoutedEventArgs e) { this.reportImportPath = this.importFromTextBox.Text; this.translationImportPath = this.translationTextBox.Text; this.reportName = this.nameTextBox.Text; this.reportDescription = this.descriptionTextBox.Text; if (!string.IsNullOrEmpty(this.reportImportPath)) { //get the xml from the file to be imported this.importedXml = ReportXmlHelper.FilesToXml(this.reportName, this.reportDescription, this.reportImportPath, this.translationImportPath); //crete the reportObject to use in the webservice FluidTrade.Guardian.TradingSupportReference.Report report = new FluidTrade.Guardian.TradingSupportReference.Report(); report.Name = this.reportName; report.ReportTypeId = DataModel.ReportType.ReportTypeKeyReportTypeCode.Find(ReportType.StaticReport).ReportTypeId; report.Xaml = this.importedXml; //make the webservice call to create the new report record on a worker thread FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(new WaitCallback(this.CreateReportCallback), report); //disable the window and do not close until the webservice is complete this.IsEnabled = false; } else { //!!!RM show an error? this.DialogResult = false; this.Close(); } }
/// <summary> /// worker thread callback to make webservice call to create a new report record that /// contains the new report xml /// </summary> /// <param name="state"></param> private void CreateReportCallback(object state) { FluidTrade.Guardian.TradingSupportReference.Report report = (FluidTrade.Guardian.TradingSupportReference.Report)state; TradingSupportWebService.CreateReport(report); //notify back to the UI thread that the webservice has completed this.Dispatcher.BeginInvoke(new System.Windows.Forms.MethodInvoker(CreateReportCallbackDone), null); }