예제 #1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                btnStart.Enabled     = false;
                txtUserName.ReadOnly = true;
                txtPassword.ReadOnly = true;
                Application.DoEvents();

                // Authentication
                if (!ValidateFields())
                {
                    throw new System.ArgumentException("Make sure to enter username/password and select the file location.");
                }

                userInfo = _auth.validateUser(txtUserName.Text, txtPassword.Text);

                if (userInfo.DealerId == 0)
                {
                    throw new System.ArgumentException("Credentials did not match.");
                }

                LogMe("Process Started :: " + DateTime.Now.ToString());
                LogMe("");

                _sourcePath = txtFilePath.Text;

                // Set File watcher
                Scannerfile_Watcher.Path         = txtFilePath.Text + @"\";
                Scannerfile_Watcher.Filter       = scannerFileName + ".*";
                Scannerfile_Watcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.FileName | NotifyFilters.LastAccess;

                Scannerfile_Watcher.EnableRaisingEvents = true;

                // Wait for the event to fire and do all the processing in Scannerfile_Watcher_Changed()
            }
            catch (Exception ex)
            {
                Scannerfile_Watcher.EnableRaisingEvents = false;
                btnStart.Enabled     = true;
                txtUserName.ReadOnly = false;
                txtPassword.ReadOnly = false;

                MessageBox.Show(ex.Message
                                , "Error Message"
                                , MessageBoxButtons.OK
                                , MessageBoxIcon.Exclamation);
            }
        }
예제 #2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                btnStart.Enabled = false;
                txtUserName.ReadOnly = true;
                txtPassword.ReadOnly = true;
                Application.DoEvents();

                // Authentication
                if (!ValidateFields())
                    throw new System.ArgumentException("Make sure to enter username/password and select the file location.");

                userInfo = _auth.validateUser(txtUserName.Text, txtPassword.Text);

                if (userInfo.DealerId == 0)
                    throw new System.ArgumentException("Credentials did not match.");

                LogMe("Process Started :: " + DateTime.Now.ToString());
                LogMe("");

                _sourcePath = txtFilePath.Text;

                // Set File watcher
                Scannerfile_Watcher.Path = txtFilePath.Text + @"\";
                Scannerfile_Watcher.Filter = scannerFileName + ".*";
                Scannerfile_Watcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.FileName | NotifyFilters.LastAccess;

                Scannerfile_Watcher.EnableRaisingEvents = true;

                // Wait for the event to fire and do all the processing in Scannerfile_Watcher_Changed()
            }
            catch (Exception ex)
            {
                Scannerfile_Watcher.EnableRaisingEvents = false;
                btnStart.Enabled = true;
                txtUserName.ReadOnly = false;
                txtPassword.ReadOnly = false;

                MessageBox.Show(ex.Message
                    , "Error Message"
                    , MessageBoxButtons.OK
                    , MessageBoxIcon.Exclamation);
            }
        }