Beispiel #1
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            try
            {
                this.btnImport.Enabled = false;
                this.UpdateStatus(string.Empty);

                if (UIUtil.CheckTextBoxEmpty(this.txtImportFile, this.lblImportFile.Text) == false)
                {
                    return;
                }

                this.UpdateStatus("Verifying file...");
                FileInfo fileInfo = new FileInfo(this.txtImportFile.Text);
                if (VerifyFile(fileInfo) == false)
                {
                    return;
                }

                this.Cursor = Cursors.WaitCursor;

                this.UpdateStatus("Parsing file...");
                Dictionary <string, List <EntityInfo> > dicList = null;
                if (ParseFile(fileInfo, out dicList) == false)
                {
                    return;
                }

                this.UpdateStatus("Start importing file...");
                if (ImportData(dicList) == false)
                {
                    return;
                }

                this.UpdateStatus("Successfully imported file");

                AutoGenerateRequests();

                this.UpdateStatus("Successfully finished all the work");
                UIUtil.ShowInfo("Successfully finished all the work.", "Succeed");
            }
            catch (Exception ex)
            {
                log.WriteLog("Error happened in Import button: " + ex.Message, ex.StackTrace);
                UIUtil.ShowError("Unexcepted Error happened: " + ex.Message, "Error");
            }
            finally
            {
                this.btnImport.Enabled = true;
                this.Cursor            = Cursors.Default;
            }
        }