Exemplo n.º 1
0
        private void btnServerFileChoose_Click(object sender, EventArgs e)
        {
            this.ButtonClicked(btnServerFileChoose, alternativeText: lblServer.Text + ":" + btnServerFileChoose.Text);
            ClearStatusMessage();

            try
            {
                var serverPath      = !string.IsNullOrEmpty(txtServerPath.Text) ? txtServerPath.Text : ServerDesktopDirectory;
                var rootBrowserPath = new List <string>();
                if (!ShowRootFolderBrowserDialog(serverPath, out rootBrowserPath, FolderBrowserType.SelectAndEditFolder))
                {
                    return;
                }

                txtServerPath.Text = rootBrowserPath.FirstOrDefault();
                ServerFileList.Clear();
                ServerFileList              = GetFiles(rootBrowserPath.FirstOrDefault());
                grdServer.DataSource        = new BindingSource(ServerFileList, null);
                btnDL.Enabled               = false;
                btnServerCheckAll.Enabled   = ServerFileList.Count > 0;
                btnServerUncheckAll.Enabled = ServerFileList.Count > 0;
            }
            catch (Exception ex)
            {
                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    grdServer.DataSource        = null;
                    btnDL.Enabled               = false;
                    btnServerCheckAll.Enabled   = false;
                    btnServerUncheckAll.Enabled = false;
                }
                else
                {
                    Debug.Fail(ex.ToString());
                    NLogHandler.WriteErrorLog(this, ex, SessionKey);
                }
            }
        }
Exemplo n.º 2
0
        private void SetServer()
        {
            try
            {
                var task = Util.GetGeneralSettingServerPathAsync(Login);
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
                var path = task.Result;
                if (!string.IsNullOrEmpty(path))
                {
                    txtServerPath.Text = path;
                }

                if (string.IsNullOrEmpty(txtServerPath.Text) || !Directory.Exists(txtServerPath.Text))
                {
                    return;
                }

                ServerFileList.Clear();
                ServerFileList              = GetFiles(txtServerPath.Text);
                grdServer.DataSource        = new BindingSource(ServerFileList, null);
                btnServerCheckAll.Enabled   = ServerFileList.Count > 0;
                btnServerUncheckAll.Enabled = ServerFileList.Count > 0;
            }
            catch (Exception ex)
            {
                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    txtServerPath.Clear();
                }
                else
                {
                    Debug.Fail(ex.ToString());
                }
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }