private void btnConnect_Click(object sender, System.EventArgs e) { if (!IsValid()) { return; } btnConnect.Enabled = false; Cursor = Cursors.WaitCursor; var uri = new Uri(txtUrl.Text); var clientCredentials = new ClientCredentials(); clientCredentials.UserName.UserName = txtUserName.Text; clientCredentials.UserName.Password = txtPassword.Text; CrmService = new OrganizationServiceProxy(uri, null, clientCredentials, null); var connected = false; try { var who = (WhoAmIResponse)CrmService.Execute(new WhoAmIRequest()); connected = true; } catch { connected = false; } if (!connected) { MessageBox.Show("Something wrong with your connection. Please try it again"); Cursor = Cursors.Default; btnConnect.Enabled = true; CrmService = null; } else { var config = DevKitCrmConfigHelper.GetDevKitCrmConfig(DTE); var crmConnection = new CrmConnection { Name = txtName.Text, Url = txtUrl.Text, UserName = txtUserName.Text, Password = txtPassword.Text }; if (config.CrmConnections == null) { config.CrmConnections = new List <CrmConnection>(); } config.CrmConnections.Add(crmConnection); config.DefaultCrmConnection = txtName.Text; DevKitCrmConfigHelper.SetDevKitCrmConfig(DTE, config); txtName.Text = ""; txtUrl.Text = "http://???/XRMServices/2011/Organization.svc"; txtUserName.Text = ""; txtPassword.Text = ""; LoadConnections(); Cursor = Cursors.Default; btnConnect.Enabled = true; } }
private void btnDefaultNetVersion_Click(object sender, System.EventArgs e) { if (MessageBox.Show("Are you sure to make this default ?", "Confirm?", MessageBoxButtons.YesNo) == DialogResult.Yes) { var config = DevKitCrmConfigHelper.GetDevKitCrmConfig(DTE); config.DefaultNetVersion = cboNetVersion.Text; DevKitCrmConfigHelper.SetDevKitCrmConfig(DTE, config); } }
private void btnConnect_Click(object sender, EventArgs e) { if (!IsValid()) { return; } btnConnect.Enabled = false; Cursor = Cursors.WaitCursor; bool connected; try { var uri = new Uri(txtUrl.Text); var clientCredentials = new ClientCredentials(); clientCredentials.UserName.UserName = txtUserName.Text; clientCredentials.UserName.Password = txtPassword.Text; var crmService = new OrganizationServiceProxy(uri, null, clientCredentials, null); crmService.Execute(new WhoAmIRequest()); connected = true; } catch { connected = false; } if (!connected) { MessageBox.Show(@"Something wrong with your connection. Please try it again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var crmConnection = new CrmConnection { Name = txtName.Text, Url = txtUrl.Text, UserName = txtUserName.Text, Password = EncryptDecrypt.EncryptString(txtPassword.Text) }; if (Config.CrmConnections == null) { Config.CrmConnections = new List <CrmConnection>(); } Config.CrmConnections.Add(crmConnection); Config.DefaultCrmConnection = txtName.Text; DevKitCrmConfigHelper.SetDevKitCrmConfig(DTE, Config); txtName.Text = ""; txtUrl.Text = @"http://???/XRMServices/2011/Organization.svc"; txtUserName.Text = ""; txtPassword.Text = ""; LoadConnections(); } Cursor = Cursors.Default; btnConnect.Enabled = true; }
private void btnOk_Click(object sender, EventArgs e) { if (Check == "1") { var executingAssembly = Assembly.GetExecutingAssembly(); var fInfo = new System.IO.FileInfo(executingAssembly.Location); var checkFile = $"{fInfo.Directory.FullName}\\Microsoft.Xrm.Tooling.Ui.Styles.dll"; if (System.IO.File.Exists(checkFile)) { Assembly.LoadFrom(checkFile); } DialogResult = DialogResult.OK; Close(); } else { Cursor = Cursors.WaitCursor; EnabledControl(false); CrmConnection = (CrmConnection)cboConnection.SelectedValue; var password = string.Empty; if (CrmConnection.Type != "ClientSecret") { try { password = EncryptDecrypt.DecryptString(CrmConnection.Password); } catch { password = CrmConnection.Password; } CrmConnection.Password = password; } if (CanConnect(CrmConnection)) { if (CrmConnection.Type != "ClientSecret") { CrmConnection.Password = EncryptDecrypt.EncryptString(password); } Config.DefaultCrmConnection = cboConnection.Text; DevKitCrmConfigHelper.SetDevKitCrmConfig(DTE, Config); DialogResult = DialogResult.OK; Cursor = Cursors.Default; Close(); } else { Cursor = Cursors.Default; MessageBox.Show(@"Something wrong with your connection. Please try it again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } EnabledControl(true); } }
private void btnOk_Click(object sender, EventArgs e) { DialogResult = DialogResult.OK; btnOk.Enabled = false; btnCancel.Enabled = false; cboConnection.Enabled = false; txtName.Enabled = false; txtUrl.Enabled = false; txtUserName.Enabled = false; txtPassword.Enabled = false; btnConnect.Enabled = false; CrmConnection = (CrmConnection)cboConnection.SelectedValue; var uri = new Uri(CrmConnection.Url); var clientCredentials = new ClientCredentials(); clientCredentials.UserName.UserName = CrmConnection.UserName; var password = string.Empty; try { password = EncryptDecrypt.DecryptString(CrmConnection.Password); } catch { password = CrmConnection.Password; CrmConnection.Password = EncryptDecrypt.EncryptString(password); DevKitCrmConfigHelper.SetDevKitCrmConfig(Dte, CrmConnection); } clientCredentials.UserName.Password = EncryptDecrypt.DecryptString(CrmConnection.Password); try { CrmService = new OrganizationServiceProxy(uri, null, clientCredentials, null); } catch { MessageBox.Show(@"Something wrong with your connection. Please try it again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Config.DefaultCrmConnection = cboConnection.Text; DevKitCrmConfigHelper.SetDevKitCrmConfig(Dte, Config); Close(); }
private void btnOk_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; EnabledControl(false); CrmConnection = (CrmConnection)cboConnection.SelectedValue; var password = string.Empty; if (CrmConnection.Type != "ClientSecret") { try { password = EncryptDecrypt.DecryptString(CrmConnection.Password); } catch { password = CrmConnection.Password; } CrmConnection.Password = password; } if (CanConnect(CrmConnection)) { if (CrmConnection.Type != "ClientSecret") { CrmConnection.Password = EncryptDecrypt.EncryptString(password); } Config.DefaultCrmConnection = cboConnection.Text; DevKitCrmConfigHelper.SetDevKitCrmConfig(DTE, Config); DialogResult = DialogResult.OK; Cursor = Cursors.Default; Close(); } else { Cursor = Cursors.Default; MessageBox.Show(@"Something wrong with your connection. Please try it again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } EnabledControl(true); }
private void SaveConnection() { var crmConnection = new CrmConnection { Name = txtName.Text, Url = txtUrl.Text, UserName = txtUserName.Text, Password = txtPassword.Text, Type = cboType.Text, }; if (crmConnection.Type != "ClientSecret") { crmConnection.Password = EncryptDecrypt.EncryptString(crmConnection.Password); } if (Config.CrmConnections == null) { Config.CrmConnections = new List <CrmConnection>(); } Config.CrmConnections.Add(crmConnection); Config.DefaultCrmConnection = txtName.Text; DevKitCrmConfigHelper.SetDevKitCrmConfig(DTE, Config); }