private void wpSelectField_AfterPageDisplayed(object sender, WizardPageChangeEventArgs e) { try { if (e.PageChangeSource == eWizardPageChangeSource.BackButton) { return; } //讀取所有工作表上的欄位資訊。 SheetHelper sheet = new SheetHelper(Context.SourceFile); IEnumerable <string> strSheetFields = sheet.Fields; //檢查所有必要欄位是否都存在,如果有缺少,就關閉精靈的下一步。 if (!RequiredFielAllAvailable(strSheetFields)) { lvSourceFieldList.Items.Clear(); return; } //取得工作表欄位中有被支援的欄位。 _sheet_fields = GetSupportFields(strSheetFields); //把前次選過的欄位打勾。 TipStyles tip = new TipStyles(sheet); List <string> usedFields = sheet.GetFieldsByColor(tip.Header.ForegroundColor); SelectPreviousUsedFields(usedFields, _sheet_fields); //檢查 Insert、Update 模式中需要限制的欄位狀況。 CheckModeDifference(); chkHideSome.Checked = false; //顯示欄位到 ListView 上。 ShowFieldsToListView(); wpSelectField.NextButtonEnabled = eWizardButtonState.Auto; } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show(ex.Message); //CurrentUser.ReportError(ex); wpSelectField.NextButtonEnabled = eWizardButtonState.False; } }
private void btnValidate_Click(object sender, EventArgs e) { try { lblCorrectCount.Text = "0"; lblErrorCount.Text = "0"; lblWarningCount.Text = "0"; //int t1 = Environment.TickCount; ProgressMessage("載入資料檢查規則…"); ValidateHelper validator = new ValidateHelper(Context, null); SheetHelper sheet = new SheetHelper(Context.SourceFile); TipStyles styles = new TipStyles(sheet); //Console.WriteLine("載入驗證規則時間:{0}", Environment.TickCount - t1); validator.ProgressChanged += new ProgressChangedEventHandler(Validator_ProgressChanged); pgValidProgress.Value = 0; //t1 = Environment.TickCount; ProgressMessage("驗證資料中…"); lnkCancelValid.Visible = true; _cancel_validate = false; cellManager = validator.Validate(sheet); lnkCancelValid.Visible = false; //Console.WriteLine("驗證時間:{0}", Environment.TickCount - t1); validator.ProgressChanged -= new ProgressChangedEventHandler(Validator_ProgressChanged); if (_cancel_validate) { wpValidation.NextButtonEnabled = eWizardButtonState.False; ProgressMessage("資料驗證已由使用者取消…"); return; } else { wpValidation.NextButtonEnabled = eWizardButtonState.True; } //t1 = Environment.TickCount; SummaryValidateInfo(cellManager); //Console.WriteLine("Summary 時間:{0}", Environment.TickCount - t1); //t1 = Environment.TickCount; sheet.ClearComments(); sheet.SetAllStyle(styles.Default); foreach (CellComment each in cellManager) { CommentItem item = each.BestComment; int row, column; row = each.RowIndex; column = each.ColumnIndex; if (item is CorrectComment) { sheet.SetComment(row, column, item.Comment); sheet.SetStyle(row, column, styles.Correct); sheet.SetValue(row, column, (item as CorrectComment).NewValue); } if (item is ErrorComment) { sheet.SetComment(row, column, item.Comment); sheet.SetStyle(row, column, styles.Error); } if (item is WarningComment) { sheet.SetComment(row, column, item.Comment); sheet.SetStyle(row, column, styles.Warning); } } //Console.WriteLine("Output Errors 時間:{0}", Environment.TickCount - t1); sheet.SetFieldsStyle(Context.SelectedFields, styles.Header); sheet.Save(Context.SourceFile); } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show(ex.Message); wpValidation.NextButtonEnabled = eWizardButtonState.False; } }