private void TextChanged_SourceFolder(object sender, EventArgs e)
        {
            string selectedPath = sourceLocationText.Text;

            if (selectedPath.EndsWith("\\"))
            {
                selectedPath = selectedPath.TrimEnd('\\');
            }

            if (selectedPath.IndexOfAny(Path.GetInvalidPathChars()) != -1)
            {
                string[] pathPartStrings = selectedPath.Split(Path.GetInvalidPathChars(), StringSplitOptions.RemoveEmptyEntries);
                selectedPath = string.Join("", pathPartStrings);
            }

            SetDisplayText(selectedPath);
            SetLocationSelection(sourceLocationText.Text);

            var urlKey = selectedPath.Split('\\')
                         .Last();

            state.ClientRootDirectory = selectedPath;
            state.FoundationUrlKey    = urlKey;
            state.FoundationId        = RequestQuery.GetFoundationId(urlKey);

            RequestQuery.RefreshFoundationProcessData(state.FoundationId);

            if (RequestQuery.FoundationProcessData.Rows.Count == 0)
            {
                processIdComboBox.DataSource = null;
                return;
            }

            processIdComboBox.DataSource    = RequestQuery.FoundationProcessData;
            processIdComboBox.DisplayMember = "ProcessDisplayText";
            processIdComboBox.ValueMember   = "ProcessId";

            string[] validDirectories = { "answers", "documents" };
            fileTypeComboBox.DataSource = null;
            if (Directory.Exists(selectedPath))
            {
                List <string> directories = Directory.GetDirectories(string.Format("{0}", selectedPath))
                                            .ToList();
                for (int x = 0; x < directories.Count(); ++x)
                {
                    directories[x] = new DirectoryInfo(directories[x]).Name;
                }

                directories = directories.Where(validDirectories.Contains)
                              .ToList();
                directories.Insert(0, "All");
                fileTypeComboBox.DataSource    = directories;
                fileTypeComboBox.SelectedIndex = 0;
            }
        }
示例#2
0
        private void BindFoundationProcessData()
        {
            try
            {
                RequestQuery.RefreshFoundationProcessData(state.FoundationId);

                if (RequestQuery.FoundationProcessData.Rows.Count == 0)
                {
                    processIdComboBox.DataSource = null;
                    return;
                }

                processIdComboBox.DataSource    = RequestQuery.FoundationProcessData;
                processIdComboBox.DisplayMember = "ProcessDisplayText";
                processIdComboBox.ValueMember   = "ProcessId";
            }
            catch (Exception eError)
            {
                MessageBox.Show(this, string.Format(FILE_COPY_ERROR_FORMAT, eError.Message), FILE_COPY_CAPTION, MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }