/// <summary> /// Reacts to connection request. /// </summary> private void ReactToConnectRequest(object o, EventArgs e) { SetupInfo setupInfo = new SetupInfo(); //The setup info to be checked and then updated to the setup info in model if valid. setupInfo.Ip = view.SetupWindow.IpTextBox; uint result; bool res = uint.TryParse(view.SetupWindow.TableBox, out result); if(!res) { view.ShowMessageBox("Table number cannot be negative"); return; } setupInfo.TableNo = uint.Parse(view.SetupWindow.TableBox); if(setupInfo.Ip.Length == 0) { view.ShowMessageBox("Please type in the target connection"); return; } string password = view.SetupWindow.Password; //Password from setup window to be tested. try { //Tests inf there is a connection to the voter box. PessimisticVoterDAO pvdao = new PessimisticVoterDAO(setupInfo.Ip, password); pvdao.StartTransaction(); pvdao.EndTransaction(); } catch (Exception e1) { if (e1.Message.Contains("Access")) { view.ShowMessageBox("Incorrect password"); return; } if (e1.Message.Contains("connect")) { view.ShowMessageBox("No connection to server. Please check connection or target address."); return; } } //feed the model with setup information. model.SetupInfo = setupInfo; model.AdminPass = password; //Tries to write setup information to the setup.conf file. try { model.WriteToConfig(); } catch (Exception e2) { view.ShowMessageBox("unable to write to config file. " + e2.StackTrace); } view.SetupWindow.Hide(); view.ScannerWindow.Show(); }
public void StaticPvdaoSet(PessimisticVoterDAO value) { Model.StaticPvdao = value; // TODO: add assertions to method ModelTest.StaticPvdaoSet(PessimisticVoterDAO) }
/// <summary> /// Initializes and starts the pessimistic voter DAO's transaction. /// </summary> public void initializeStaticDAO() { staticPvdao = new PessimisticVoterDAO(setupInfo.Ip, adminPass); //Initialize the pvdao. staticPvdao.StartTransaction(); }