private void CbDatabaseName_DropDownOpened(object sender, EventArgs e) { try { Cursor = Cursors.Wait; cbDatabaseName.Items.Clear(); TCNodeConfig tcnode = new TCNodeConfig( this.SqlServerName, this.Authentication, this.SqlUserName, this.DatabaseName, this.Password ); List <string> localDatabases = tcnode.SqlDatabases; foreach (string database in localDatabases) { cbDatabaseName.Items.Add(database); } } catch (Exception err) { lbConnectionStatus.Text = err.Message; lbConnectionStatus.Foreground = new SolidColorBrush(Colors.Red); } finally { Cursor = Cursors.Arrow; } }
void InstallManufacturingDemo() { try { Cursor = Cursors.Wait; progressBar.IsIndeterminate = true; btnServices.IsEnabled = false; btnManufacturing.IsEnabled = false; TCNodeConfig tcnode = new TCNodeConfig( this.SqlServerName, this.Authentication, this.SqlUserName, this.DatabaseName, this.Password ); tcnode.CommandTimeout = int.Parse(cbManDemoTimeout.Text); if ((bool)rbManDemoActivities.IsChecked) { tcnode.InstallMode = DemoInstallMode.Activities; } else if ((bool)rbManDemoCreateOrders.IsChecked) { tcnode.InstallMode = DemoInstallMode.Orders; } else if ((bool)rbManDemoInvoiceOrder.IsChecked) { tcnode.InstallMode = DemoInstallMode.Invoices; } else if ((bool)rbManDemoPayInvoices.IsChecked) { tcnode.InstallMode = DemoInstallMode.Payments; } BackgroundWorker manDemo = new BackgroundWorker { WorkerReportsProgress = false }; manDemo.DoWork += ManDemo_DoWork;; manDemo.RunWorkerCompleted += ManDemo_RunWorkerCompleted;; manDemo.RunWorkerAsync(tcnode); lbManufacturingStatus.Text = Properties.Resources.ExecutionInProgress; } catch (Exception err) { lbManufacturingStatus.Text = $"{err.Source}.{err.TargetSite.Name}: {err.Message}"; lbManufacturingStatus.Foreground = new SolidColorBrush(Colors.Red); progressBar.IsIndeterminate = false; btnServices.IsEnabled = true; btnManufacturing.IsEnabled = true; } finally { Cursor = Cursors.Arrow; } }
public void UpgradeNode() { try { TCNodeConfig tcnode = new TCNodeConfig( this.SqlServerName, this.Authentication, this.SqlUserName, this.DatabaseName, this.Password ); BackgroundWorker upgrader = new BackgroundWorker { WorkerReportsProgress = true }; upgrader.DoWork += Upgrader_DoWork; upgrader.ProgressChanged += Installer_ProgressChanged; upgrader.RunWorkerCompleted += Upgrader_RunWorkerCompleted; upgrader.RunWorkerAsync(tcnode); } catch (Exception err) { lbUpgradeStatus.Text = $"{err.Source}.{err.TargetSite.Name}: {err.Message}"; lbUpgradeStatus.Foreground = new SolidColorBrush(Colors.Red); tabsMain.SelectedItem = pageUpgrades; } finally { progressBar.Value = 0; } }
private void InstallNode(TCNodeConfig tcnode) { try { BackgroundWorker installer = new BackgroundWorker { WorkerReportsProgress = true }; installer.DoWork += Installer_DoWork; installer.ProgressChanged += Installer_ProgressChanged; installer.RunWorkerCompleted += Installer_RunWorkerCompleted; installer.RunWorkerAsync(tcnode); } catch (Exception err) { lbConnectionStatus.Text = $"{err.Source}.{err.TargetSite.Name}: {err.Message}"; lbConnectionStatus.Foreground = new SolidColorBrush(Colors.Red); tabsMain.SelectedItem = pageConnection; } finally { progressBar.Value = 0; } }
private void InstallBasicSetup() { try { Cursor = Cursors.Wait; TCNodeConfig tcnode = new TCNodeConfig( this.SqlServerName, this.Authentication, this.SqlUserName, this.DatabaseName, this.Password ); if (!tcnode.IsConfigured) { short financialMonth = (short)(cbFinancialYear.SelectedIndex + 1); tcnode.InstallBasicSetup( financialMonth, tbGovAccountName.Text, tbBankName.Text, tbBankAddress.Text, tbDummyAccount.Text, tbCurrentAccount.Text, tbCA_SortCode.Text, tbCA_AccountNumber.Text, tbReserveAccount.Text, tbRA_SortCode.Text, tbRA_AccountNumber.Text ); btnBasicSetup.IsEnabled = false; lbBasicSetupStatus.Text = string.Format(Properties.Resources.BasicSetupInstalled, tcnode.DatabaseName); btnServices.IsEnabled = true; lbServicesStatus.Foreground = new SolidColorBrush(Colors.Blue); lbServicesStatus.Text = string.Format(Properties.Resources.InstallDemoData, tcnode.SqlServerName, tcnode.DatabaseName); btnManufacturing.IsEnabled = true; lbManufacturingStatus.Foreground = new SolidColorBrush(Colors.Blue); lbManufacturingStatus.Text = string.Format(Properties.Resources.InstallDemoData, tcnode.SqlServerName, tcnode.DatabaseName); } else { lbBasicSetupStatus.Foreground = new SolidColorBrush(Colors.Red); lbBasicSetupStatus.Text = string.Format(Properties.Resources.InstanceIsConfigured, tcnode.DatabaseName, tcnode.SqlServerName); } } catch (Exception err) { lbBasicSetupStatus.Text = $"{err.Source}.{err.TargetSite.Name}: {err.Message}"; lbBasicSetupStatus.Foreground = new SolidColorBrush(Colors.Red); } finally { Cursor = Cursors.Arrow; } }
private void ManDemo_DoWork(object sender, DoWorkEventArgs e) { try { TCNodeConfig tcnode = (TCNodeConfig)e.Argument; tcnode.InstallManufacturingDemo(); } catch (Exception err) { MessageBox.Show($"{err.Message}", $"{err.Source}.{err.TargetSite.Name}", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Upgrader_DoWork(object sender, DoWorkEventArgs e) { try { TCNodeConfig tcnode = (TCNodeConfig)e.Argument; tcnode.UpgradeNode(sender as BackgroundWorker); } catch (Exception err) { MessageBox.Show($"{err.Message}", $"{err.Source}.{err.TargetSite.Name}", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { lbAssemblyVersion.Content = TCNodeConfig.CurrentVersion.ToString(); using (TCNodeConfig config = new TCNodeConfig()) { SqlServerName = config.SqlServerName; Authentication = config.Authentication; SqlUserName = config.SqlUserName; DatabaseName = config.DatabaseName; } if (DatabaseName.Length > 0) { TestConnection(); } }
private void BusinessDetails() { try { Cursor = Cursors.Wait; TCNodeConfig tcnode = new TCNodeConfig( this.SqlServerName, this.Authentication, this.SqlUserName, this.DatabaseName, this.Password ); tcnode.ConfigureNode( accountCode: tbAccountCode.Text, businessName: tbBusinessName.Text, fullName: tbFullName.Text, businessAddress: tbBusinessAddress.Text, businessEmailAddress: tbEmailAddress.Text, userEmailAddress: tbEmailAddress.Text, phoneNumber: tbPhoneNumber.Text, companyNumber: tbCompanyNumber.Text, vatNumber: tbVatNumber.Text, calendarCode: tbCalendarCode.Text, uocName: cbUocName.Text ); lbBusinessStatus.Text = string.Format(Properties.Resources.ConfigurationSuccess, this.cbDatabaseName.Text); lbBusinessStatus.Foreground = new SolidColorBrush(Colors.Blue); TestConnection(); } catch (Exception err) { lbBusinessStatus.Text = $"{err.Source}.{err.TargetSite.Name}: {err.Message}"; lbBusinessStatus.Foreground = new SolidColorBrush(Colors.Red); } finally { Cursor = Cursors.Arrow; } }
private void TestConnection() { try { Cursor = Cursors.Wait; using (TCNodeConfig tcnode = new TCNodeConfig( this.SqlServerName, this.Authentication, this.SqlUserName, this.DatabaseName, this.Password)) { if (tcnode.Authenticated) { if (tcnode.IsEmptyDatabase) { btnTestConnection.IsEnabled = false; lbConnectionStatus.Foreground = new SolidColorBrush(Colors.Red); lbConnectionStatus.Text = Properties.Resources.ExecutionInProgress; DisableFunctions(); InstallNode(tcnode); } else { lbConnectionStatus.Foreground = new SolidColorBrush(Colors.Blue); lbConnectionStatus.Text = Properties.Resources.ConnectionSucceeded; if (tcnode.IsTCNode) { lbUpgrade.Content = string.Format(Properties.Resources.UpgradeHeader, tcnode.DatabaseName); if (cbUocName.Items.Count == 0) { List <string> uocNames = tcnode.UnitOfChargeNames; foreach (string uocName in uocNames) { cbUocName.Items.Add(uocName); } cbUocName.Text = tcnode.UnitOfChargeDetault; } if (!tcnode.IsUpToDate) { lbUpgradeStatus.Text = string.Format(Properties.Resources.InstanceNeedsUpgrading, tcnode.DatabaseName, tcnode.InstalledVersion.ToString(), TCNodeConfig.CurrentVersion.ToString()); lbUpgradeStatus.Foreground = new SolidColorBrush(Colors.Red); btnUpgrade.IsEnabled = true; tabsMain.SelectedItem = pageUpgrades; } else { lbUpgradeStatus.Text = string.Format(Properties.Resources.InstanceIsUpToDate, tcnode.DatabaseName, tcnode.InstalledVersion.ToString()); lbUpgradeStatus.Foreground = new SolidColorBrush(Colors.Black); btnUpgrade.IsEnabled = false; if (!tcnode.IsInitialised) { btnBusinessDetails.IsEnabled = true; lbBusinessStatus.Foreground = new SolidColorBrush(Colors.Blue); lbBusinessStatus.Text = Properties.Resources.ConfigureEnabled; tabsMain.SelectedItem = pageBusinessDetails; } else { btnBusinessDetails.IsEnabled = false; lbBusinessStatus.Foreground = new SolidColorBrush(Colors.Red); lbBusinessStatus.Text = string.Format(Properties.Resources.ConfigureDisabled, tcnode.DatabaseName); btnAddUser.IsEnabled = true; lbAddUserStatus.Foreground = new SolidColorBrush(Colors.Blue); switch (tcnode.Authentication) { case AuthenticationMode.SqlServer: tbUsrLoginName.Text = this.SqlUserName; lbAddUserStatus.Text = string.Format(Properties.Resources.AddSqlUserToDatabase, tcnode.DatabaseName, tcnode.SqlServerName); pbUsrPassword.Password = this.Password; cbCreateLogin.IsChecked = true; cbCreateLogin.IsEnabled = true; cbLoginAsUser.IsEnabled = true; break; case AuthenticationMode.Windows: tbUsrLoginName.Text = tcnode.WinUserName; lbAddUserStatus.Text = string.Format(Properties.Resources.AddWinUserToDatabase, tcnode.DatabaseName, tcnode.SqlServerName); pbUsrPassword.Password = string.Empty; cbCreateLogin.IsChecked = false; cbLoginAsUser.IsChecked = false; cbCreateLogin.IsEnabled = false; cbLoginAsUser.IsEnabled = false; break; } lbAddUserStatus.Foreground = new SolidColorBrush(Colors.Blue); var calendarCodes = tcnode.CalendarCodes; foreach (string calendarCode in calendarCodes) { cbUsrCalendarCode.Items.Add(calendarCode); } if (cbUsrCalendarCode.Items.Count > 0) { cbUsrCalendarCode.SelectedIndex = 0; } tabsMain.SelectedItem = pageAddUsers; if (tcnode.IsConfigured) { btnBasicSetup.IsEnabled = false; lbBasicSetupStatus.Foreground = new SolidColorBrush(Colors.Red); lbBasicSetupStatus.Text = string.Format(Properties.Resources.InstanceIsConfigured, tcnode.DatabaseName, tcnode.SqlServerName); btnServices.IsEnabled = true; lbServicesStatus.Foreground = new SolidColorBrush(Colors.Blue); lbServicesStatus.Text = string.Format(Properties.Resources.InstallDemoData, tcnode.SqlServerName, tcnode.DatabaseName); btnManufacturing.IsEnabled = true; lbManufacturingStatus.Foreground = new SolidColorBrush(Colors.Blue); lbManufacturingStatus.Text = string.Format(Properties.Resources.InstallDemoData, tcnode.SqlServerName, tcnode.DatabaseName); } else { btnBasicSetup.IsEnabled = true; lbBasicSetupStatus.Foreground = new SolidColorBrush(Colors.Blue); lbBasicSetupStatus.Text = string.Format(Properties.Resources.InstallBasicSetupuration, tcnode.DatabaseName, tcnode.SqlServerName); btnServices.IsEnabled = false; lbServicesStatus.Foreground = new SolidColorBrush(Colors.Red); lbServicesStatus.Text = Properties.Resources.InstanceIsUnconfigured; btnManufacturing.IsEnabled = false; lbManufacturingStatus.Foreground = new SolidColorBrush(Colors.Red); lbManufacturingStatus.Text = Properties.Resources.InstanceIsUnconfigured; } } } } else { lbConnectionStatus.Foreground = new SolidColorBrush(Colors.Red); lbConnectionStatus.Text = Properties.Resources.UnrecognisedDatasource; DisableFunctions(); } } } else { lbConnectionStatus.Foreground = new SolidColorBrush(Colors.Red); lbConnectionStatus.Text = Properties.Resources.ConnectionFailed; DisableFunctions(); } } } catch (Exception err) { lbConnectionStatus.Text = $"{err.Source}.{err.TargetSite.Name}: {err.Message}"; lbConnectionStatus.Foreground = new SolidColorBrush(Colors.Red); btnBusinessDetails.IsEnabled = false; lbBusinessStatus.Foreground = new SolidColorBrush(Colors.Red); lbBusinessStatus.Text = Properties.Resources.DataSourceNotFound; tabsMain.SelectedItem = pageConnection; } finally { Cursor = Cursors.Arrow; } }
private void AddUser() { try { Cursor = Cursors.Wait; TCNodeConfig tcnode = new TCNodeConfig( this.SqlServerName, this.Authentication, this.SqlUserName, this.DatabaseName, this.Password ); bool createLogin = (bool)cbCreateLogin.IsChecked && (bool)cbCreateLogin.IsEnabled; bool isAdministrator = (bool)cbIsAdministrator.IsChecked; tcnode.AddUser( tbUsrLoginName.Text, pbUsrPassword.Password, createLogin, tbUsrFullName.Text, tbUsrAddress.Text, tbUsrEmailAddress.Text, tbUsrMobile.Text, cbUsrCalendarCode.Text, isAdministrator ); if ((bool)cbLoginAsUser.IsChecked && (bool)cbLoginAsUser.IsEnabled) { switch (tcnode.Authentication) { case AuthenticationMode.SqlServer: this.SqlUserName = this.tbUsrLoginName.Text; this.pbPassword.Password = this.pbUsrPassword.Password; break; case AuthenticationMode.Windows: this.SqlUserName = this.tbUsrLoginName.Text; break; } TestConnection(); tabsMain.SelectedItem = pageDemos; tabsDemos.SelectedItem = pageBasicSetup; } else { lbAddUserStatus.Text = string.Format(Properties.Resources.UserAddedSuccessfully, tbUsrLoginName.Text); } } catch (Exception err) { lbAddUserStatus.Text = $"{err.Source}.{err.TargetSite.Name}: {err.Message}"; lbAddUserStatus.Foreground = new SolidColorBrush(Colors.Red); } finally { Cursor = Cursors.Arrow; } }