Пример #1
0
        private void anonymousClicked(object sender, RoutedEventArgs e)
        {
            anonymousCheck aCheck = new anonymousCheck(this, "Button", ftpAddress.Text, usernameTextBox.Text, passwordTextBox.Text);
            Thread         th     = new Thread(aCheck.DoWork);

            th.IsBackground = true;
            th.Start();
        }
Пример #2
0
        private void anonymousKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key.ToString() == "Return")
            {
                anonymousCheck aCheck = new anonymousCheck(this, "Button", ftpAddress.Text, usernameTextBox.Text, passwordTextBox.Text);
                Thread         th     = new Thread(aCheck.DoWork);

                th.IsBackground = true;
                th.Start();
            }
        }
Пример #3
0
        public void carryOutSubmission(bool reSubmission)
        {
            if (reSubmission == false)
            {
                //Anonymous Check Thread
                anonymousCheck aCheck = new anonymousCheck(this, "NoButton", ftpAddress.Text, usernameTextBox.Text, passwordTextBox.Text);
                Thread         th     = new Thread(aCheck.DoWork);

                th.IsBackground = true;
                th.Start();
                //Anonymous Check Thread
            }

            fInfo1.IsReadOnly = false;
            fInfo2.IsReadOnly = false;

            if (ftpAddress.Text == null)
            {
                //MessageBox.Show("Please enter an ftp address");
            }
            else if (folderNames.Text == null)
            {
                //MessageBox.Show("Please enter folder names");
            }

            int i, slashCounter = 0;

            for (i = 0; i < ftpAddress.Text.Length; i++)
            {
                if (ftpAddress.Text[i] == '/' && i > 5)
                {
                    slashCounter++;
                }
            }

            char[] tempCharArrayLocal = new char[ftpAddress.Text.Length - slashCounter];

            for (i = 0, slashCounter = 0; i < ftpAddress.Text.Length; i++)
            {
                if (ftpAddress.Text[i] == '/' && i > 5)
                {
                    slashCounter++;
                }
                if (slashCounter < 1)
                {
                    tempCharArrayLocal[i] = ftpAddress.Text[i];
                }
            }

            string slashRemovalString = new string(tempCharArrayLocal);

            string ftpText = null;

            if (intervalTextBox.Text != "")
            {
                int temp;

                Int32.TryParse(intervalTextBox.Text, out temp);

                if (temp < 60)
                {
                    interval = intervalTextBox.Text;
                }
                else
                {
                    if (reSubmission == false)
                    {
                        MessageBox.Show("Interval has to be between 0 and 59");
                    }

                    intervalTextBox.Text = interval;
                }
            }

            if (!ftpAddress.Text.Contains("ftp://"))
            {
                ftpText = "ftp://" + slashRemovalString + "/\r\n" + verboseCheckBool.ToString() + "\r\n" + interval + "\r\n" + usernameTextBox.Text + "\r\n" + passwordTextBox.Text;
            }
            else
            {
                ftpText = slashRemovalString + "/\r\n" + verboseCheckBool.ToString() + "\r\n" + interval + "\r\n" + usernameTextBox.Text + "\r\n" + passwordTextBox.Text;
            }

            if (ftpAddress.Text == "")
            {
                ftpText         = configRetrieved[0] + "\r\n" + verboseCheckBool.ToString() + "\r\n" + interval + "\r\n" + usernameTextBox.Text + "\r\n" + passwordTextBox.Text;
                ftpAddress.Text = ftpText;
            }

            System.IO.File.WriteAllText(ftpAddressFilePathLocal, ftpText);

            if (folderNames.Text.Length > 0 && (firstEdit == false || folderNames.Text[0] == 32))
            {
                bool   spaceFound    = false;
                char[] tempCharArray = new char[folderNames.Text.Length];

                for (i = 0, k = 0; i < folderNames.Text.Length; i++)
                {
                    if (spaceFound == true && folderNames.Text[i] != 32)
                    {
                        spaceFound = false;
                    }

                    if (i == 0 && folderNames.Text[i] == 32)
                    {
                        spaceFound = true;
                    }

                    if (folderNames.Text[i] == 13)
                    {
                        if (i < folderNames.Text.Length - 2 && folderNames.Text[i + 1] == 10 && folderNames.Text[i + 2] == 32)
                        {
                            i++;                //skipping the carriage (13) //loop increment will skip the line feed (10)
                            spaceFound = true;
                        }
                        else if (i == folderNames.Text.Length - 2)
                        {
                            //empty line
                            i++;    //skipping the carriage
                            spaceFound = true;
                        }
                        else
                        {
                            //legal carriages
                        }
                    }

                    if (spaceFound == false)
                    {
                        tempCharArray[k] = folderNames.Text[i];
                        k++;
                    }
                }

                char[] filteredCharArray = new char[k];

                for (i = 0; i < k; i++)
                {
                    filteredCharArray[i] = tempCharArray[i];
                }

                String tempString = new String(filteredCharArray);

                System.IO.File.WriteAllText(folderNamesFilePathLocal, tempString);
            }
            else
            {
                System.IO.File.WriteAllText(folderNamesFilePathLocal, folderNames.Text);
            }

            if (reSubmission == false)
            {
                MessageBox.Show("Changes Saved! Please wait for the changes to take effect!", "FTPAutoSync Configure");
            }

            fInfo1.IsReadOnly = true;
            fInfo2.IsReadOnly = true;
        }