public Int32 MoveContainer(Int32 movedContainerId, Int32 toContainerId, int user_id) { SqlCommandBuilder commandBuilder; commandBuilder = new SqlCommandBuilder("p_MoveContainer"); commandBuilder.AddParameter(ContainerData.CONTAINER_ID, movedContainerId); if (ChiasmaDepData.IsValidId(toContainerId)) { commandBuilder.AddParameter(ContainerData.TO_CONTAINER_ID, toContainerId); } commandBuilder.AddParameter(ContainerData.AUTHORITY_ID, user_id); return(ExecuteCommand(commandBuilder)); }
private void MoveContainer(IGenericContainer moveContainer, IGenericContainer toContainer, int userId) { // Moves containers into target container. If tocontainer is null // the moveContainers is moved out from currect location try { if (toContainer.GetContainerType() == ContainerType.Uncontained) { toContainer = null; } // Move the containers. ChiasmaDepData.BeginTransaction(); GenericContainerManager.MoveGenericContainer(moveContainer, toContainer, userId); ChiasmaDepData.CommitTransaction(); } catch { ChiasmaDepData.RollbackTransaction(); throw; } }
private bool SetAuthorityMappingForBarcode(string userBarcode) { if (!UserManager.IsUserBarcode(userBarcode)) { MessageBox.Show("This barcode could not be linked to a Chiasma user!", "Login failure", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } try { ChiasmaDepData.BeginTransaction(); UserManager.SetAuthorityMappingFromBarcode(userBarcode); ChiasmaDepData.CommitTransaction(); } catch (System.Exception ex) { ChiasmaDepData.RollbackTransaction(); HandleError("Could not logon to database", ex); } return(true); }
private Boolean Login() { // BarCodeController barCodeController; Boolean isLoginOk = false; string userBarcode = ""; if (Config.GetApplicationMode() == Config.ApplicationMode.Lab) { // LAB MODE // Enable background bar code listening. KeyPreview = true; if (!LoginDataBase()) { return(false); } do { // Get login information. MyLoginWithBarcodeDialog = new LoginWithBarcodeDialog(); // Login by bar code is currently not supported. // barCodeController = new BarCodeController(MyLoginForm); // barCodeController.BarCodeReceived += ExecuteBarCode; if (MyLoginWithBarcodeDialog.ShowDialog() == DialogResult.OK) { userBarcode = MyLoginWithBarcodeDialog.Barcode; MyLoginWithBarcodeDialog = null; } else { // The user cancelled. return(false); } } // Try to login to the database. while (!SetAuthorityMappingForBarcode(userBarcode)); UserManager.Refresh(); Text = Config.GetDialogTitleStandard() + " - " + UserManager.GetCurrentUser().GetName(); // Start the activity timer. It is used for automatic logout in lab mode. this.ActivityTimer.Enabled = true; MyActivityCounter = 0; isLoginOk = true; } else { // OFFICE MODE isLoginOk = LoginDataBase(); SetAuthorityMappingFromSysUser(); } if (!UserManager.GetCurrentUser().IsAccountActive()) { throw new Exception("User " + UserManager.GetCurrentUser().GetName() + " has been inactivated"); } if (isLoginOk) { // Cache data. // This is done in order to avoid DateReader already open exception. ChiasmaDepData.Refresh(); //ActivityTimer.Enabled = true; } return(isLoginOk); }
public bool Login(bool versionControl) { // BarCodeController barCodeController; Boolean isLoginOk = false; String version; String applicationName; string barcode; if (Config.GetApplicationMode() == Config.ApplicationMode.Lab) { // LAB MODE // Enable background bar code listening. KeyPreview = true; if (!LoginDataBase()) { return(false); } do { // Get login information. MyLoginWithBarcodeDialog = new LoginWithBarcodeDialog(); // Login by bar code is currently not supported. // barCodeController = new BarCodeController(MyLoginForm); // barCodeController.BarCodeReceived += ExecuteBarCode; if (MyLoginWithBarcodeDialog.ShowDialog() == DialogResult.OK) { barcode = MyLoginWithBarcodeDialog.Barcode; MyLoginWithBarcodeDialog = null; } else { // The user cancelled. LogoutDatabase(); return(false); } } // Try to login to the database. while (!SetAuthorityMappingForBarcode(barcode)); UserManager.Refresh(); Text = Config.GetDialogTitleStandard() + " - " + UserManager.GetCurrentUser().GetName(); // Start the activity timer. It is used for automatic logout in lab mode. ActivityTimer.Enabled = false; MyActivityCounter = 0; isLoginOk = true; } else { // OFFICE MODE isLoginOk = LoginDataBase(); SetAuthorityMappingFromSysUser(); } if (!UserManager.GetCurrentUser().IsAccountActive()) { throw new Exception("User " + UserManager.GetCurrentUser().GetName() + " has been inactivated"); } if (isLoginOk) { if (versionControl) { // Get version number of the current assembly. version = Assembly.GetExecutingAssembly().GetName().Version.Major + "." + Assembly.GetExecutingAssembly().GetName().Version.Minor + "." + Assembly.GetExecutingAssembly().GetName().Version.Build + "." + Assembly.GetExecutingAssembly().GetName().Version.Revision; // Get the name of the current assembly. applicationName = Assembly.GetExecutingAssembly().GetName().Name; // Make sure the current application is allowed to connect. if (!ChiasmaDepData.Database.AuthenticateApplication(applicationName, version)) { HandleError("The current version of this program is not allowed to connect to the database.", null); return(false); } } // Cache data. // This is done in order to avoid DateReader already open exception. ChiasmaDepData.Refresh(); } return(isLoginOk); }