public void RetriveAuditHistoryForRecords(string identificator, bool allFields, string fieldToExtract) { this.fileName = fileName; this.identificator = identificator; this.fieldToExtract = fieldToExtract; this.allFields = allFields; if (BackgroundWorkerExtractAuditHistory.IsBusy != true) { progressExportData.Step = 1; progressExportData.Maximum = entitiesList.Entities.Count; this.Focus(); BackgroundWorkerExtractAuditHistory.RunWorkerAsync(); } }
private void BackgroundWorkerExtractAuditHistory_DoWork(object sender, DoWorkEventArgs e) { AuditHistoryManager auditHistoryManager = new AuditHistoryManager(Service); foreach (Entity entity in entitiesList.Entities) { if (BackgroundWorkerExtractAuditHistory.CancellationPending) { e.Cancel = true; return; } try { string keyValue = string.IsNullOrEmpty(entity.GetAttributeValue <string>(identificator)) ? string.Empty : entity.GetAttributeValue <string>(identificator); if (allFields) { lsStory.AddRange(auditHistoryManager.GetAuditHistoryForRecord(entity.Id, entity.LogicalName, entity.GetAttributeValue <string>(identificator))); } else { lsStory.AddRange(auditHistoryManager.GetAuditHistoryForRecordAndField(entity.Id, entity.LogicalName, fieldToExtract, entity.GetAttributeValue <string>(identificator))); } BackgroundWorkerExtractAuditHistory.ReportProgress(1, keyValue); } catch (Exception ex) { DialogResult dialogResult = MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK); return; } } //MessageBox.Show(MessageAuditHistoryExtracted, TitleExportSuccess, MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnCancel_Click(object sender, EventArgs e) { BackgroundWorkerExtractAuditHistory.CancelAsync(); }