Esempio n. 1
0
        private async Task <bool> generate(string url, string proj)
        {
            EpicorDetails details = new EpicorDetails();

            details.BaseClass    = BaseClassTextBox.Text;
            details.APIURL       = url;
            details.Project      = proj;
            details.Namespace    = NamespaceTextBox.Text;
            details.useNamespace = (bool)UseNamespaceCheckBox.IsChecked;
            details.useBaseClass = (bool)UseBaseClassCheckBox.IsChecked;
            details.Username     = usernameTextBox.Text;
            details.Password     = passwordTextBox.Password;

            var test = await service.generateCode(services, details);

            if (test)
            {
                MessageBox.Show("Success");
            }
            else
            {
                MessageBox.Show("Somehing went wrong");
            }
            return(true);
        }
Esempio n. 2
0
        private bool isvalidURL(string url)
        {
            EpicorDetails details = new EpicorDetails();

            if ((bool)useCredentialsCheckBox.IsChecked)
            {
                details.Username = usernameTextBox.Text;
                details.Password = passwordTextBox.Password;
            }
            try
            {
                var valid = service.getServices(url, details);
                if (valid.workspace != null && valid.workspace.collection != null && valid.workspace.collection.Count() == 0)
                {
                    MessageBox.Show("Service is invalid");
                    return(false);
                }
            }
            catch (WebException ex)
            {
                if (ex.Response != null)
                {
                    using (WebResponse response = ex.Response)
                    {
                        HttpWebResponse httpResponse = (HttpWebResponse)response;
                        MessageBox.Show(string.Format("Error code: {0}", httpResponse.StatusDescription));
                        string text = "";
                        using (Stream data = response.GetResponseStream())
                            using (var reader = new StreamReader(data))
                            {
                                // text is the response body
                                text = reader.ReadToEnd();
                            }
                        MessageBox.Show(text);
                        return(false);
                    }
                }
                else
                {
                    MessageBox.Show(ex.Message);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
        private void PopulateService(TextBox textBox, ListBox listBox, string type)
        {
            if (string.IsNullOrEmpty(textBox.Text))
            {
                MessageBox.Show("Services URL is Required");
            }
            if (!isvalidURL(textBox.Text))
            {
                return;
            }

            EpicorDetails details = new EpicorDetails();

            if ((bool)useCredentialsCheckBox.IsChecked)
            {
                details.Username = usernameTextBox.Text;
                details.Password = passwordTextBox.Password;
            }

            services = service.getServices(textBox.Text, details);
            services.workspace.collection = services.workspace.collection.Where(o => o.href.ToUpper().StartsWith(type)).ToArray <serviceWorkspaceCollection>();
            listBox.ItemsSource           = services.workspace.collection.Select(o => o.href);

            try
            {
                var files = Directory.EnumerateFiles(System.IO.Path.GetDirectoryName(ERPProjectTextBox.Text), "*.cs");
                foreach (var file in files)
                {
                    var filename = System.IO.Path.GetFileNameWithoutExtension(file);
                    if (listBox.Items.Contains(filename))
                    {
                        listBox.SelectedItems.Add(listBox.Items[listBox.Items.IndexOf(filename)]);
                    }
                }
            }
            catch (Exception ex)
            {
                var error = ex;
                // Something went wrong when trying to automatically select the existing services from the service list.
            }
        }
        private void PopulateService(TextBox textBox, ListBox listBox, string type)
        {
            if (string.IsNullOrEmpty(textBox.Text))
            {
                MessageBox.Show("Services URL is Required");
            }
            if (!isvalidURL(textBox.Text))
            {
                return;
            }

            EpicorDetails details = new EpicorDetails();

            if ((bool)useCredentialsCheckBox.IsChecked)
            {
                details.Username = usernameTextBox.Text;
                details.Password = passwordTextBox.Text;
            }

            services = service.getServices(textBox.Text, details);
            services.workspace.collection = services.workspace.collection.Where(o => o.href.ToUpper().StartsWith(type)).ToArray <serviceWorkspaceCollection>();
            listBox.ItemsSource           = services.workspace.collection.Select(o => o.href);
        }