Exemplo n.º 1
0
        /// <summary>
        /// 建構式,傳入精靈參數
        /// </summary>
        /// <param name="args"></param>
        public SelectFields(ArgDictionary args)
            : base(args)
        {
            InitializeComponent();
            NextButtonTitle = "開始驗證";
            mArgs = args;
            mImportOption = mArgs["ImportOption"] as ImportFullOption;
            mImportWizard = mArgs["EMBA.ImportWizard"] as ImportWizard;
            mSelectableFields = mArgs["SelectableFields"] as List<string>;
            mImportOption.SelectedFields.Clear();

            this.Text = mImportWizard.ValidateRule.Root.GetAttributeText("Name") + "-" + this.Text;
            this.Text += "(" + CurrentStep + "/" + TotalStep + ")"; //功能名稱(目前頁數/總頁數)

            RefreshFields();

            chkSelectAll.CheckedChanged += (sender,e) =>
            {
                foreach (ListViewItem Item in lvSourceFieldList.Items)
                {
                    Item.Checked = chkSelectAll.Checked;
                }
            };

            //若是沒有使用者可選擇的欄位,則直接跳到下個畫面;目前設這會有問題...
            //if (mSelectableFields.Count == 0)
            //    this.OnNextButtonClick();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 建構式,傳入精靈參數
        /// </summary>
        /// <param name="args"></param>
        public SelectValidate(ArgDictionary args)
            : base(args)
        {
            InitializeComponent();

            //將精靈參數存起來用
            mArgs = args;
            mImportOption = mArgs["ImportOption"] as ImportFullOption;
            mImportWizard = mArgs["EMBA.ImportWizard"] as ImportWizard;
            mResultFilename = Path.Combine(Constants.ValidationReportsFolder, Path.GetFileNameWithoutExtension(mImportOption.SelectedDataFile) + "(驗證報告).xls");
            this.Text = mImportWizard.ValidateRule.Root.GetAttributeText("Name") + "-" + this.Text;
            this.Text += "(" + CurrentStep + "/" + TotalStep + ")"; //功能名稱(目前頁數/總頁數)

            //  若某個匯入程式不使用「進階設定」的畫面,則「下一步」要變更為「開始匯入」
            if (!mImportWizard.ShowAdvancedForm)
                NextButtonTitle = "開始匯入";

            NextButtonEnabled = false;
            btnViewResult.Enabled = false;
            #region 初始化事件
            //加入可停止執行的事件內容
            lnkCancelValid.Click += (sender, e) => worker.CancelAsync();

            //加入檢查驗證結果程式碼
            btnViewResult.Click += (sender, e) =>
            {
                try
                {
                    Process.Start(mResultFilename);
                }
                catch (Exception ex)
                {
                    FISCA.Presentation.Controls.MsgBox.Show(ex.Message);
                }
            };
            #endregion

            StartValidate();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 建構式,傳入精靈參數
        /// </summary>
        /// <param name="args"></param>
        public SelectImport(ArgDictionary args)
            : base(args)
        {
            InitializeComponent();

            this.PreviousButtonVisible = false;
            this.NextButtonTitle = "完成";
            this.NextButtonEnabled = false;

            //將精靈參數存起來用
            mArgs = args;
            mImportOption = mArgs["ImportOption"] as ImportFullOption;
            mImportWizard = mArgs["EMBA.ImportWizard"] as ImportWizard;
            mValidatedInfo = mArgs["ValidatedInfo"] as ValidatedInfo;

            mImportName = mImportWizard.ValidateRule.Root.GetAttributeText("Name");

            this.Text = mImportName + "-" + this.Text;
            this.Text += "(" + CurrentStep + "/" + TotalStep + ")"; //功能名稱(目前頁數/總頁數)
            this.txtResult.Text = "匯入中…";
            this.btnViewResult.Visible = false;
            this.btnAgent.Visible = false;
            //this.TitleText += "(" + CurrentStep + "/" + TotalStep + ")"; //功能名稱(目前頁數/總頁數)
        }
Exemplo n.º 4
0
        /// <summary>
        /// 建構式,傳入精靈選項
        /// </summary>
        /// <param name="args"></param>
        public SelectSource(ArgDictionary args)
            : base(args)
        {
            InitializeComponent();

            //初始化參數
            mArgs = args;
            mImportWizard = args["EMBA.ImportWizard"] as ImportWizard;
            mImportOption = TryGetOption();
            mImportName = mImportWizard.ValidateRule.Root.GetAttributeText("Name");
            this.Text = mImportName + "-選擇檔案與匯入方式" + "(" + CurrentStep + "/" + TotalStep + ")";

            //載入驗證規則及XSLT
            LoadValudateRule();

            //在使用者選擇資料表時,將資料表的欄位都記錄下來
            lstSheetNames.SelectedIndexChanged += (sender, e) =>
            {
                mSheetHelper.SwitchSeet("" + lstSheetNames.SelectedItem);
                mImportOption.SelectedSheetName = "" + lstSheetNames.SelectedItem;
                mImportOption.SheetFields = mSheetHelper.Fields;
                this.NextButtonEnabled = ValidateNext();
            };

            //檢視驗證規則
            btnViewRule.Click += (sender, e) =>
            {
                XmlViewForm ViewForm = new XmlViewForm();

                ViewForm.PopXml(mImportName,mImportOption.SelectedValidateFile);

                ViewForm.ShowDialog();
            };

            //檢視填表說明
            btnViewRuleExcel.Click += (sender, e) =>
            {
                Workbook book = new Workbook();

                string BookAndSheetName = mImportName +"(空白表格)";

                if (!string.IsNullOrEmpty(BookAndSheetName))
                    book.Worksheets[0].Name = BookAndSheetName;

                int Position = 0;

                foreach (XElement Element in mImportWizard.ValidateRule.Root.Element("FieldList").Elements("Field"))
                {
                    StringBuilder strCommentBuilder = new StringBuilder();

                    string Name = Element.GetAttributeText("Name");
                    bool Required = Element.GetAttributeBool("Required",false);

                    book.Worksheets[0].Cells[0, Position].PutValue(Name);
                    book.Worksheets[0].Cells[0, Position].Style.HorizontalAlignment = TextAlignmentType.Center;
                    book.Worksheets[0].Cells[0, Position].Style.VerticalAlignment = TextAlignmentType.Center;

                    if (Required)
                    {
                        book.Worksheets[0].Cells[0, Position].Style.BackgroundColor  = System.Drawing.Color.Red;
                        strCommentBuilder.AppendLine("此為必要欄位。");
                    }

                    foreach(XElement SubElement in Element.Elements("Validate"))
                        strCommentBuilder.AppendLine(SubElement.GetAttributeText("Description"));

                    book.Worksheets[0].Comments.Add(0,(byte)Position);
                    book.Worksheets[0].Comments[0,Position].Note = strCommentBuilder.ToString() ;
                    book.Worksheets[0].Comments[0, Position].WidthInch = 3;

                    Position++;
                }

                book.Worksheets[0].AutoFitColumns();
                //  開啟「空白格式」匯入檔
                string emptyTemplateFile = Path.Combine(Constants.ValidationReportsFolder, BookAndSheetName + ".xls");
                try
                {
                    book.Save(emptyTemplateFile);
                    Process.Start(emptyTemplateFile);
                }
                catch (Exception ex)
                {
                    FISCA.Presentation.Controls.MsgBox.Show(ex.Message);
                }
            };

            //選擇來源資料檔案
            btnSelectFile.Click += (sender, e) =>
            {
                DialogResult dr = SelectSourceFileDialog.ShowDialog();

                if (dr == DialogResult.OK)
                {
                    try
                    {
                        //記錄來源檔案名稱
                        string FileName = SelectSourceFileDialog.FileName;

                        txtSourceFile.Text = SelectSourceFileDialog.FileName;
                        mImportOption.SelectedDataFile = FileName;
                        mSheetHelper = new SheetHelper(FileName);

                        //將資料表列表顯示在畫面上
                        lstSheetNames.Items.Clear();

                        foreach (Worksheet sheet in mSheetHelper.Book.Worksheets)
                            lstSheetNames.Items.Add(sheet.Name);

                        lstSheetNames.SelectedIndex = 0;
                    }
                    catch (Exception ve)
                    {
                        MsgBox.Show(ve.Message);
                    }
                }
            };

            //將前一步不出現,下一步先失效
            this.PreviousButtonVisible = false;
            this.NextButtonEnabled = false;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 建構式,傳入精靈參數
        /// </summary>
        /// <param name="args"></param>
        public SelectKey(ArgDictionary args)
            : base(args)
        {
            InitializeComponent();
            mArgs = args;
            mImportOption = args["ImportOption"] as ImportFullOption;
            mImportWizard = args["EMBA.ImportWizard"] as ImportWizard;
            this.Text = mImportWizard.ValidateRule.Root.GetAttributeText("Name") + "-" + this.Text;
            this.Text += "(" + CurrentStep + "/" + TotalStep + ")"; //功能名稱(目前頁數/總頁數)

            #region 將使用者可選擇的鍵值顯示在畫面上
            mSelectableKeyFields = args["SelectableKeyFields"] as Dictionary<string, List<string>>;
            int cboIdFieldLen = cboIdField.Width;

            foreach (string key in mSelectableKeyFields.Keys)
            {
                ComboItem item = new ComboItem(key);
                item.Tag = mSelectableKeyFields[key];

                cboIdField.Items.Add(item);

                if (key.Length > cboIdFieldLen)
                    cboIdFieldLen = key.Length;
            }

            if (cboIdField.Items.Count > 0)
            {
                cboIdField.SelectedIndex = 0;
                //cboIdField.Width = cboIdFieldLen;
            }
            #endregion

            #region 將使用者可選擇的資料動作
            ImportAction Actions = mImportWizard.GetSupportActions();

            bool IsInsert = (Actions & ImportAction.Insert) == ImportAction.Insert;
            bool IsUpdate = (Actions & ImportAction.Update) == ImportAction.Update;
            bool IsInsertOrUpdate = (Actions & ImportAction.InsertOrUpdate) == ImportAction.InsertOrUpdate;
            bool IsCover = (Actions & ImportAction.Cover) == ImportAction.Cover;
            bool IsDelete = (Actions & ImportAction.Delete) == ImportAction.Delete;

            if (IsInsert)
                lstActions.Items.Add("新增資料");
            if (IsUpdate)
                lstActions.Items.Add("更新資料");
            if (IsInsertOrUpdate)
                lstActions.Items.Add("新增或更新資料");
            if (IsCover)
                lstActions.Items.Add("覆蓋資料");

            lstActions.SelectedIndexChanged += (sender, e) =>
            {
                switch ("" + lstActions.SelectedItem)
                {
                    case "新增資料": lblImportActionMessage.Text = "此選項是將所有資料新增到資料庫中,不會對現有的資料進行任何修改動作。"; break;
                    case "更新資料": lblImportActionMessage.Text = "此選項將修改資料庫中的現有資料,會依據您所指定的識別欄修改資料庫中具有相同識別的資料。"; break;
                    case "新增或更新資料": lblImportActionMessage.Text = "此選項是將資料新增或更新到資料庫中,會針對您的資料來自動判斷新增或更新。"; break;
                    case "覆蓋資料": lblImportActionMessage.Text = "此選項是將資料庫中的資料都先刪除再全部新增"; break;
                    case "刪除資料": lblImportActionMessage.Text = "此選項將依匯入資料中的鍵值刪除資料庫中的現有資料,請您務必小心謹慎使用。"; break;
                };
            };

            lstActions.KeyDown  += (sender, e) =>
            {
                if (e.KeyData == System.Windows.Forms.Keys.Delete)
                    if (IsDelete)
                        lstActions.Items.Add("刪除資料");
            };

            lstActions.SelectedIndex = 0;

            #endregion
        }