public LoginSSO() { // Login to Support CS SSO - just use a browser control to hit the SSO page and then // sniff for the Session Id and use that to login to the API // started with the WPF browser control but was very buggy! searching the internet said // the windows forms one was more stable, switched and seems to be fine // TODO - timeout detection - when salesforce timesout, there is a javascript error from the control // I think when SForce is trying to display the "You are about to be logged out due to inactivity" // this should be trapped and a message shown to the user with a better logout message/process InitializeComponent(); Utility.setTheme(this); RadWindowInteropHelper.SetAllowTransparency(this, false); _d = Globals.ThisAddIn.getData(); _settings = Globals.ThisAddIn.getSettings(); _local = Globals.ThisAddIn.GetLocalSettings(); // try the windows form browser _webBrowser1 = new System.Windows.Forms.WebBrowser(); this.wfh1.Child = _webBrowser1; _webBrowser1.Navigated += _webBrowser1_Navigated; _webBrowser1.DocumentCompleted += _webBrowser1_DocumentCompleted; // stop the reminders - salesforce puts up a reminder window - it doesn't work though // we get an IE window with an error so just cancel it _webBrowser1.NewWindow += _webBrowser1_NewWindow; }
public Login() { InitializeComponent(); Utility.setTheme(this); _d = Globals.ThisAddIn.getData(); _settings = Globals.ThisAddIn.getSettings(); _local = Globals.ThisAddIn.GetLocalSettings(); // depending on the setting hide the demo logins GetLogins(_local.ShowAllLogins); if (radComboDemoLogins.Items.Count > 0) { radComboDemoLogins.SelectedIndex = 0; } // hid the theme pcicker and the local dbase themepick1.Visibility = System.Windows.Visibility.Hidden; label4.Visibility = System.Windows.Visibility.Hidden; themepick1.SelectedIndex = 0; cbLocal.Visibility = System.Windows.Visibility.Hidden; tbUserName.Focus(); tbUserName.SelectAll(); }
public void SetInstance(LocalSettings.Instances ?inst) { if (inst != null && inst != LocalSettings.Instances.Prod) { Globals.Ribbons.Ribbon1.btnLoginSSO.Label = inst.ToString(); Globals.Ribbons.Ribbon1.sbtnLoginSSO.Label = inst.ToString(); } }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { // get the local settings and set the theme Logger.Log("get the local settings and set the theme"); _localSettings = new LocalSettings(); this.SetTheme(); //Create the Salesforce connection _d = new Data(); _p = new Processing(); _p.Hide(); if (_localSettings.SSOLogin) { // switch off normal login Globals.Ribbons.Ribbon1.btnLogin.Visible = false; if (_localSettings.ShowAllLogins) { Globals.Ribbons.Ribbon1.btnLoginSSO.Visible = false; Globals.Ribbons.Ribbon1.sbtnLoginSSO.Visible = true; } else { Globals.Ribbons.Ribbon1.btnLoginSSO.Visible = true; Globals.Ribbons.Ribbon1.sbtnLoginSSO.Visible = false; } } else { Globals.Ribbons.Ribbon1.btnLogin.Visible = true; Globals.Ribbons.Ribbon1.btnLoginSSO.Visible = false; Globals.Ribbons.Ribbon1.sbtnLoginSSO.Visible = false; } // set the name of the Ribbon button depending on the selected instances if (_localSettings.Inst != null && _localSettings.Inst != LocalSettings.Instances.Prod) { Globals.Ribbons.Ribbon1.btnLoginSSO.Label = _localSettings.Inst.ToString(); Globals.Ribbons.Ribbon1.sbtnLoginSSO.Label = _localSettings.Inst.ToString(); } if (_localSettings.Debug) { Globals.Ribbons.Ribbon1.gpDebug.Visible = true; // switch on normal login Globals.Ribbons.Ribbon1.btnLogin.Visible = true; Globals.Ribbons.Ribbon1.btnLoginSSO.Label = "SSO"; } else { Globals.Ribbons.Ribbon1.gpDebug.Visible = false; } // ---------------------------------------------------------------------------------------------------------------------------------------------------- // Change Nov : Auto Login bool autologin = false; if (autologin && _localSettings.Debug) { this.SetRibbon(); //Globals.ThisAddIn.ProcessingStart("AutoLogin - remember to switch off!"); // This can be used for testing so you don't have to login every time // set the autologin about to true // then add the details to the login call - should be username, password, sforce token, sforce url, login description to show in the about string rtn = _d.Login("[email protected]", "pass@word1", "LGZ0rTkNnuksEetJr1vrG0YS", "https://test.salesforce.com", "AutoLogin - Sales"); if (rtn == "") { // get the settings bool gotSettings = true; DataReturn settings = _d.GetStaticResource("RibbonSettings"); if (!settings.success || settings.strRtn == "") { // get the default settings var uri = new Uri("pack://application:,,,/AxiomIRISRibbon;component/Resources/Settings.json"); byte[] bjson = AxiomIRISRibbon.Properties.Resources.Settings; string sjson = Encoding.Default.GetString(bjson, 0, bjson.Length - 1); try { _settings = new SForceEdit.Settings(sjson); gotSettings = true; } catch (Exception eSet) { System.Windows.MessageBoxResult rslt = System.Windows.MessageBox.Show("Settings did not load : " + eSet.Message, "Axiom IRIS", System.Windows.MessageBoxButton.OK); } } else { try { _settings = new SForceEdit.Settings(settings.strRtn); gotSettings = true; } catch (Exception eSet) { System.Windows.MessageBoxResult rslt = System.Windows.MessageBox.Show("Settings did not load : " + eSet.Message, "Axiom IRIS", System.Windows.MessageBoxButton.OK); } } if (!gotSettings) return; DataReturn dr = Utility.HandleData(_d.LoadDefinitions()); Globals.Ribbons.Ribbon1.LoginOK(); Globals.Ribbons.Ribbon1.gpDebug.Visible = true; } //---------------------------------- } else { } Globals.ThisAddIn.ProcessingStop("LoggedIN"); // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ _editWindows = new Dictionary<string, Edit>(); _editZoomWindows = new Dictionary<string, Edit>(); //Add in the Save handler this.Application.DocumentBeforeSave += new Word.ApplicationEvents4_DocumentBeforeSaveEventHandler(Application_DocumentBeforeSave); //Add a loader this.Application.DocumentOpen += new Word.ApplicationEvents4_DocumentOpenEventHandler(Application_DocumentOpen); //add a handler to tidy up sidebars this.Application.DocumentChange += Application_DocumentChange; }
public void SaveLocalSettings(LocalSettings s) { _localSettings = s; }
public void Login(LocalSettings.Instances ?Inst) { lblLoginMessage.Text = ""; _webBrowser1.Navigate("about:blank"); // set the busy indicator running bsyInd.IsIndeterminate = true; bsyInd.IsBusy = true; bsyInd.BusyContent = "Logging In ..."; _soapversion = _local.SoapVersion; if (!_local.Debug) { this.wfh1.Visibility = System.Windows.Visibility.Hidden; } else { this.wfh1.Visibility = System.Windows.Visibility.Visible; } if (Inst == null) { Inst = _local.Inst; } _instance = Inst; if (Inst == LocalSettings.Instances.Dev) { _url = _local.DevUrl; _orgid = _local.DevOrgId; _instancename = "SSO Dev (" + _url + ")"; } else if (Inst == LocalSettings.Instances.IT) { _url = _local.ITUrl; _orgid = _local.ITOrgId; _instancename = "SSO IT (" + _url + ")"; } else if (Inst == LocalSettings.Instances.UAT) { _url = _local.UATUrl; _orgid = _local.UATOrgId; _instancename = "SSO UAT (" + _url + ")"; } else if (Inst == LocalSettings.Instances.Prod) { _url = _local.ProdUrl; _orgid = _local.ProdOrgId; _instancename = "SSO Prod (" + _url + ")"; } // navigate the web page to the SSO string url = _url; // if not inside CS make this test.salesforce.com // url = "https://test.salesforce.com"; if (url != "") { try { _webBrowser1.Navigate(url); Utility.DoEvents(); } catch(Exception e){ bsyInd.IsBusy = false; lblLoginMessage.Text = "There has been a problem with the SSO login: "******"No url setup for the SSO Login - please update settings"; } }