Example #1
0
 /// <summary>
 /// Show the Upload Language button if the user is allowed to upload languages.
 /// </summary>
 private void CheckUploadLanguagePermission()
 {
     if (!_blnLoggedIn)
         cmdUploadLanguage.Visible = false;
     else
     {
         translationSoapClient objService = OmaeHelper.GetTranslationService();
         try
         {
             cmdUploadLanguage.Visible = objService.CanUploadLanguage(_strUserName);
         }
         catch
         {
             cmdUploadLanguage.Visible = false;
         }
         objService.Close();
     }
 }
Example #2
0
        /// <summary>
        /// Set all of the BasicHttpBinding properties and configure the EndPoint. This is done to avoid the need for an app.config file to be shipped with the application.
        /// </summary>
        public static translationSoapClient GetTranslationService()
        {
            BasicHttpBinding objBinding = new BasicHttpBinding
            {
                Name                   = "translationSoap",
                CloseTimeout           = TimeSpan.FromMinutes(1),
                OpenTimeout            = TimeSpan.FromMinutes(1),
                ReceiveTimeout         = TimeSpan.FromMinutes(10),
                SendTimeout            = TimeSpan.FromMinutes(1),
                AllowCookies           = false,
                BypassProxyOnLocal     = false,
                HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
                MaxBufferSize          = 5242880, // 5 MB
                MaxReceivedMessageSize = 5242880, // 5 MB
                MaxBufferPoolSize      = 524288,
                MessageEncoding        = WSMessageEncoding.Text,
                TextEncoding           = Encoding.UTF8,
                TransferMode           = TransferMode.Buffered,
                UseDefaultWebProxy     = true,
                ReaderQuotas           =
                {
                    MaxDepth               =      32,
                    MaxStringContentLength = 8388608,
                    MaxArrayLength         = 5242880,
                    MaxBytesPerRead        =    4096,
                    MaxNameTableCharCount  = 32565
                },
                Security =
                {
                    Mode      = BasicHttpSecurityMode.None,
                    Transport = { ClientCredentialType = HttpClientCredentialType.None,ProxyCredentialType                           = HttpProxyCredentialType.None, Realm = string.Empty },
                    Message   = { ClientCredentialType = BasicHttpMessageCredentialType.UserName, AlgorithmSuite      = System.ServiceModel.Security.SecurityAlgorithmSuite.Default }
                }
            };



            const string    strEndPoint        = "http://www.chummergen.com/dev/chummer/omae/translation.asmx";
            EndpointAddress objEndPointAddress = new EndpointAddress(strEndPoint);

            translationSoapClient objService = new translationSoapClient(objBinding, objEndPointAddress);

            return(objService);
        }
Example #3
0
        /// <summary>
        /// Set all of the BasicHttpBinding properties and configure the EndPoint. This is done to avoid the need for an app.config file to be shippped with the application.
        /// </summary>
        public translationSoapClient GetTranslationService()
        {
            BasicHttpBinding objBinding = new BasicHttpBinding();

            objBinding.Name                   = "translationSoap";
            objBinding.CloseTimeout           = TimeSpan.FromMinutes(1);
            objBinding.OpenTimeout            = TimeSpan.FromMinutes(1);
            objBinding.ReceiveTimeout         = TimeSpan.FromMinutes(10);
            objBinding.SendTimeout            = TimeSpan.FromMinutes(1);
            objBinding.AllowCookies           = false;
            objBinding.BypassProxyOnLocal     = false;
            objBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
            objBinding.MaxBufferSize          = 5242880; // 5 MB
            objBinding.MaxReceivedMessageSize = 5242880; // 5 MB
            objBinding.MaxBufferPoolSize      = 524288;
            objBinding.MessageEncoding        = WSMessageEncoding.Text;
            objBinding.TextEncoding           = System.Text.Encoding.UTF8;
            objBinding.TransferMode           = TransferMode.Buffered;
            objBinding.UseDefaultWebProxy     = true;

            objBinding.ReaderQuotas.MaxDepth = 32;
            objBinding.ReaderQuotas.MaxStringContentLength = 8388608;
            objBinding.ReaderQuotas.MaxArrayLength         = 5242880;
            objBinding.ReaderQuotas.MaxBytesPerRead        = 4096;
            objBinding.ReaderQuotas.MaxNameTableCharCount  = 32565;

            objBinding.Security.Mode = BasicHttpSecurityMode.None;
            objBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
            objBinding.Security.Transport.ProxyCredentialType  = HttpProxyCredentialType.None;
            objBinding.Security.Transport.Realm = string.Empty;
            objBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
            objBinding.Security.Message.AlgorithmSuite       = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;

            const string    strEndPoint        = "http://www.chummergen.com/dev/chummer/omae/translation.asmx";
            EndpointAddress objEndPointAddress = new EndpointAddress(strEndPoint);

            translationSoapClient objService = new translationSoapClient(objBinding, objEndPointAddress);

            return(objService);
        }
Example #4
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();
        }
        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();
        }
Example #6
0
        /// <summary>
        /// Set all of the BasicHttpBinding properties and configure the EndPoint. This is done to avoid the need for an app.config file to be shippped with the application.
        /// </summary>
        public translationSoapClient GetTranslationService()
        {
            BasicHttpBinding objBinding = new BasicHttpBinding();
            objBinding.Name = "translationSoap";
            objBinding.CloseTimeout = TimeSpan.FromMinutes(1);
            objBinding.OpenTimeout = TimeSpan.FromMinutes(1);
            objBinding.ReceiveTimeout = TimeSpan.FromMinutes(10);
            objBinding.SendTimeout = TimeSpan.FromMinutes(1);
            objBinding.AllowCookies = false;
            objBinding.BypassProxyOnLocal = false;
            objBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
            objBinding.MaxBufferSize = 5242880; // 5 MB
            objBinding.MaxReceivedMessageSize = 5242880; // 5 MB
            objBinding.MaxBufferPoolSize = 524288;
            objBinding.MessageEncoding = WSMessageEncoding.Text;
            objBinding.TextEncoding = System.Text.Encoding.UTF8;
            objBinding.TransferMode = TransferMode.Buffered;
            objBinding.UseDefaultWebProxy = true;

            objBinding.ReaderQuotas.MaxDepth = 32;
            objBinding.ReaderQuotas.MaxStringContentLength = 8388608;
            objBinding.ReaderQuotas.MaxArrayLength = 5242880;
            objBinding.ReaderQuotas.MaxBytesPerRead = 4096;
            objBinding.ReaderQuotas.MaxNameTableCharCount = 32565;

            objBinding.Security.Mode = BasicHttpSecurityMode.None;
            objBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
            objBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
            objBinding.Security.Transport.Realm = "";
            objBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
            objBinding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;

            const string strEndPoint = "http://www.chummergen.com/dev/chummer/omae/translation.asmx";
            EndpointAddress objEndPointAddress = new EndpointAddress(strEndPoint);

            translationSoapClient objService = new translationSoapClient(objBinding, objEndPointAddress);

            return objService;
        }