Example #1
0
 private void cboConnections_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cboConnections.SelectedIndex != ListBox.NoMatches)
     {
         try
         {
             string conn    = cboConnections.SelectedItem.ToString();
             string tenant  = Settings.Get(IniSection.Connection, conn, IniKey.Tenant);
             string service = cboWWS2.ReturnValue();
             string version = Settings.Get(IniSection.WDWebServices, IniKey.Version);
             txtTenant.Text   = tenant;
             txtUsername.Text = Settings.Get(IniSection.Connection, conn, IniKey.Username);
             lnkApiUrl.Text   = WDWebService.BuildApiUrl(conn, service, version);
             Settings.Set(IniSection.State, cboConnections.Name, conn);
             lblPassword.Text = "";
             string password = Settings.Get(IniSection.Connection, conn, IniKey.Password);
             if (!String.IsNullOrEmpty(password))
             {
                 lblPassword.Text = password;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error selecting a connection. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Example #2
0
 private void cboWWS2_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cboWWS2.SelectedIndex != ListBox.NoMatches && cboConnections.SelectedIndex != ListBox.NoMatches)
     {
         try
         {
             Settings.Set(IniSection.State, cboWWS2.Name, cboWWS2.ReturnValue());
             string conn    = cboConnections.SelectedItem.ToString();
             string service = cboWWS2.ReturnValue();
             lnkApiUrl.Text = WDWebService.BuildApiUrl(conn, service, txtVersion2.Text);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Web Service Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Example #3
0
 private void txtVersion2_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (String.IsNullOrEmpty(txtVersion2.Text))
         {
             txtVersion2.Text = verDefault;
         }
         Settings.Set(IniSection.WDWebServices, IniKey.Version, txtVersion2.Text);
         if (cboConnections.SelectedIndex != ListBox.NoMatches)
         {
             string conn    = cboConnections.SelectedItem.ToString();
             string service = cboWWS2.ReturnValue();
             lnkApiUrl.Text = WDWebService.BuildApiUrl(conn, service, txtVersion2.Text);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error saving version. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #4
0
        public WDMainForm()
        {
            InitializeComponent();

            try
            {
                Cursor          = Cursors.WaitCursor;
                lblWarning.Text = "";
                // Tool Tips
                toolTip1.SetToolTip(lnkXFormInst, Properties.Resources.Instructions_XForm);
                toolTip1.SetToolTip(lnkInstCallAPI, Properties.Resources.Instructions_CallAPI);
                toolTip1.SetToolTip(lnkApiUrl, Properties.Resources.Instructions_Click2Copy2Clipboard);
                toolTip1.SetToolTip(lnkInstAddlActions, Properties.Resources.Instructions_AdditionalActions);
                tabControl.DrawItem += new DrawItemEventHandler(tabControl_DrawItem);
                // Web Services Download
                string wdWebServicesURL = Settings.Get(IniSection.WDWebServices, IniKey.URL);
                string iniFolder        = Path.GetDirectoryName(Settings.iniFilePath);

                if (!File.Exists(iniFolder + "\\" + wwsFile))
                {
                    try
                    {
                        // Clear any older versions
                        foreach (string file in Directory.GetFiles(iniFolder, wwsFilePart + "*.*"))
                        {
                            File.Delete(file);
                        }
                        wdWebServices = WDWebService.Download(WWSURL);
                        File.WriteAllText(iniFolder + "\\" + wwsFile, JsonSerializer.Serialize(wdWebServices));
                    }
                    finally
                    {
                        Settings.Set(IniSection.WDWebServices, IniKey.URL, WWSURL);
                    }
                }
                else
                {
                    try
                    {
                        wdWebServices = WDWebService.Load(File.ReadAllText(iniFolder + "\\" + wwsFile));
                    }
                    catch (Exception ex)
                    {
                        Settings.Set(IniSection.WDWebServices, IniKey.URL, "");
                    }
                }
                foreach (KeyValuePair <string, string> service in wdWebServices)
                {
                    try
                    {
                        Uri uri = new Uri(service.Key);
                        verDefault = uri.Segments[uri.Segments.Length - 2].Replace("/", "");
                    }
                    catch
                    {
                        // ignore exception
                    }
                    break;
                }

                // Turn Off Event Handling During Init
                this.cboWWS1.SelectedIndexChanged -= new System.EventHandler(this.cboWWS1_SelectedIndexChanged);
                this.cboWWS2.SelectedIndexChanged -= new System.EventHandler(this.cboWWS2_SelectedIndexChanged);
                this.cboXSD.SelectedIndexChanged  -= new System.EventHandler(this.cboXSD_SelectedIndexChanged);
                this.txtVersion1.TextChanged      -= new System.EventHandler(this.txtVersion1_TextChanged);
                this.txtVersion2.TextChanged      -= new System.EventHandler(this.txtVersion2_TextChanged);

                // Web Services
                cboWWS1.DisplayMember = "Value";
                cboWWS1.ValueMember   = "Key";
                cboWWS1.DataSource    = new BindingSource(wdWebServices, null);

                cboWWS2.DisplayMember = "Value";
                cboWWS2.ValueMember   = "Key";
                cboWWS2.DataSource    = new BindingSource(wdWebServices, null);

                // Connections
                ConnectionsLoad();

                // Init
                // Workday Studio Files
                string dir = Settings.Get(IniSection.WDStudio, IniKey.Workspace);
                if (!String.IsNullOrEmpty(dir) && Directory.Exists(dir))
                {
                    txtWDStudioFolder.Text = dir;
                    string filter = Settings.Get(IniSection.WDStudio, IniKey.WorkspaceFilter);
                    if (!String.IsNullOrEmpty(filter))
                    {
                        txtFilter.Text = filter;
                        TreeViewUpdate(txtWDStudioFolder.Text, txtFilter.Text);
                    }
                }
                pnlTreeView.Size = new Size(450, 609);

                // Web Services
                cboWWS1.SelectedIndex = cboWWS1.FindStringExact(Settings.Get(IniSection.State, cboWWS1.Name));
                cboXSD_Load(cboWWS1.ReturnKey());
                cboXSD.SelectedIndex = cboXSD.FindStringExact(Settings.Get(IniSection.State, cboXSD.Name));
                txtVersion1.Text     = Settings.Get(IniSection.WDWebServices, IniKey.Version);
                if (String.IsNullOrEmpty(txtVersion1.Text))
                {
                    txtVersion1.Text = verDefault;
                }

                // API
                cboConnections.SelectedIndex = cboConnections.FindStringExact(Settings.Get(IniSection.State, cboConnections.Name));
                cboWWS2.SelectedIndex        = cboWWS2.FindStringExact(Settings.Get(IniSection.State, cboWWS2.Name));
                txtVersion2.Text             = Settings.Get(IniSection.WDWebServices, IniKey.Version);
                if (cboConnections.SelectedIndex != ListBox.NoMatches && cboWWS2.SelectedIndex != ListBox.NoMatches)
                {
                    string conn    = cboConnections.SelectedItem.ToString();
                    string service = cboWWS2.ReturnValue();
                    lnkApiUrl.Text = WDWebService.BuildApiUrl(conn, service, txtVersion2.Text);
                }
                if (String.IsNullOrEmpty(txtVersion2.Text))
                {
                    txtVersion2.Text = verDefault;
                }

                // Hide Update Tab
                Octokit release           = new Octokit();
                Task <GitHubRelease> task = Task.Run(() => release.GetLatest());
                task.Wait();
                if (task.Result != null & task.Result.Version != null & task.Result.Description != null)
                {
                    txtVersionDescr.Text = task.Result.Version + Environment.NewLine + task.Result.Description;
                }
                if (!task.Result.UpdateAvailable)
                {
                    tabControl.Controls.Remove(tabUpdate);
                }

                // Init as Soap
                radSoap.Checked = true;
                radGet.Checked  = true;

                // Init IntSyst Tab
                txtConnection.Text = cboConnections.SelectedItem.ToString();
                txtTenant2.Text    = txtTenant.Text;
                txtUsername2.Text  = txtUsername.Text;

                // Initial Tab
                string tab = Settings.Get(IniSection.State, tabControl.Name);
                if (!String.IsNullOrEmpty(tab))
                {
                    try
                    {
                        tabControl.SelectTab(tab);
                    }
                    catch
                    {
                        // ignore exception
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "ERP Helper Start", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // Turn On Event Handling
                this.cboWWS1.SelectedIndexChanged += new System.EventHandler(this.cboWWS1_SelectedIndexChanged);
                this.cboWWS2.SelectedIndexChanged += new System.EventHandler(this.cboWWS2_SelectedIndexChanged);
                this.cboXSD.SelectedIndexChanged  += new System.EventHandler(this.cboXSD_SelectedIndexChanged);
                this.txtVersion1.TextChanged      += new System.EventHandler(this.txtVersion1_TextChanged);
                this.txtVersion2.TextChanged      += new System.EventHandler(this.txtVersion2_TextChanged);
                Cursor = Cursors.Default;
            }
        }