Ejemplo n.º 1
0
        private void cmdUpload_Click(object sender, EventArgs e)
        {
            // Make sure a file has been selected.
            if (txtFilePath.Text == "")
            {
                MessageBox.Show("Please select a language file to upload.", "No Language File Selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            byte[]   bytFile      = File.ReadAllBytes(txtFilePath.Text);
            string[] strFileParts = txtFilePath.Text.Split(Path.DirectorySeparatorChar);
            string   strFileName  = strFileParts[strFileParts.Length - 1];

            translationSoapClient objService = _objOmaeHelper.GetTranslationService();

            try
            {
                int intResult = objService.UploadLanguage(_strUserName, strFileName, bytFile);

                if (intResult == RESULT_SUCCESS)
                {
                    MessageBox.Show(MESSAGE_SUCCESS, "File Upload", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (intResult == RESULT_UNAUTHORIZED)
                {
                    MessageBox.Show(MESSAGE_UNAUTHORIZED, "File Upload", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (intResult == RESULT_INVALID_FILE)
                {
                    MessageBox.Show(MESSAGE_INVALID_FILE, "File Upload", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (EndpointNotFoundException)
            {
                MessageBox.Show(NO_CONNECTION_MESSAGE, NO_CONNECTION_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            objService.Close();
        }
Ejemplo n.º 2
0
        private void cmdUpload_Click(object sender, EventArgs e)
        {
            // Make sure a file has been selected.
            if (string.IsNullOrEmpty(txtFilePath.Text))
            {
                Program.MainForm.ShowMessageBox("Please select a language file to upload.", "No Language File Selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            byte[] bytFile     = File.ReadAllBytes(txtFilePath.Text);
            string strFileName = Path.GetFileName(txtFilePath.Text);

            translationSoapClient objService = OmaeHelper.GetTranslationService();

            try
            {
                int intResult = objService.UploadLanguage(_strUserName, strFileName, bytFile);

                if (intResult == RESULT_SUCCESS)
                {
                    Program.MainForm.ShowMessageBox(MESSAGE_SUCCESS, "File Upload", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (intResult == RESULT_UNAUTHORIZED)
                {
                    Program.MainForm.ShowMessageBox(MESSAGE_UNAUTHORIZED, "File Upload", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (intResult == RESULT_INVALID_FILE)
                {
                    Program.MainForm.ShowMessageBox(MESSAGE_INVALID_FILE, "File Upload", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (EndpointNotFoundException)
            {
                Program.MainForm.ShowMessageBox(NO_CONNECTION_MESSAGE, NO_CONNECTION_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            objService.Close();
        }