public Stream startOnDemandPackage(String sites, String packageName) { BoolTO response = new BoolTO() { tf = true }; try { response.fault = new FaultTO() { message = "Not yet implemented" }; return(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(gov.va.medora.utils.JsonUtils.Serialize <BoolTO>(response)))); new OrchestratorDao().prioritizeConfigs(sites, packageName); return(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(gov.va.medora.utils.JsonUtils.Serialize <BoolTO>(response)))); } catch (Exception exc) { response.fault = new FaultTO(exc); return(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(gov.va.medora.utils.JsonUtils.Serialize <BoolTO>(response)))); } }
public BoolTO hasPermission(string uid, string permissionName) { BoolTO result = new BoolTO(); if (!(MdwsUtils.isAuthorizedConnection(mySession) == "OK")) { result.fault = new FaultTO("Connections not ready for operation", "Need to login?"); } else if (String.IsNullOrEmpty(uid)) { result.fault = new FaultTO("Empty UID"); } else if (String.IsNullOrEmpty(permissionName)) { result.fault = new FaultTO("Empty permission name"); } if (result.fault != null) { return(result); } try { AbstractPermission p = new gov.va.medora.mdo.dao.vista.MenuOption(permissionName); bool f = User.hasPermission(mySession.ConnectionSet.BaseConnection, uid, p); result = new BoolTO(f); } catch (Exception exc) { result.fault = new FaultTO(exc); } return(result); }
/// <summary> /// Delete a session by it's ID and all the corresponding saved requests /// </summary> /// <param name="sessionId">The session ID to be deleted</param> /// <returns> /// BoolTO.trueOrFalse = true if successful. /// BoolTO.trueOrFalse = false if session ID not found. /// BoolTO.fault will be != null on error /// </returns> public BoolTO deleteSession(string sessionId) { if (String.IsNullOrEmpty(sessionId) || sessionId.Length != 24) // valid session IDs are 24 characters { throw new ArgumentException("Need a valid session ID!"); } BoolTO result = new BoolTO(); SqlConnection conn = new SqlConnection(); SqlTransaction tx = null; try { conn = getConnection(); tx = conn.BeginTransaction(); SqlDataAdapter adapter = buildDeleteSessionAdapter(sessionId, conn, tx); int i = adapter.DeleteCommand.ExecuteNonQuery(); tx.Commit(); if (i == 0) { result.trueOrFalse = false; // query succeeded but no rows were affected } else { result.trueOrFalse = true; } return(result); } catch (Exception exc) { if (tx != null && tx.Connection != null) // transaction connection should be null if completed { tx.Rollback(); } result.fault = new FaultTO(exc); return(result); } finally { conn.Close(); if (tx != null) { tx.Dispose(); } } }
/// <summary> /// Using the configured SQL connection string, opens a connection to the database /// </summary> /// <returns>BoolTO with true value if read was successful, FaultTO otherwise</returns> public BoolTO canConnect() { BoolTO result = new BoolTO(); SqlConnection conn = new SqlConnection(_connectionString); try { conn.Open(); result.trueOrFalse = true; } catch (Exception exc) { result.fault = new FaultTO(exc); } finally { conn.Close(); } return(result); }
public BoolTO isValidStopCode(string stopCodeId) { BoolTO result = new BoolTO(); try { MdwsUtils.checkNullArgs(MdwsUtils.getArgsDictionary( System.Reflection.MethodInfo.GetCurrentMethod().GetParameters(), new List <object>() { stopCodeId })); result.trueOrFalse = new EncounterApi().isValidStopCode(_mySession.ConnectionSet.BaseConnection, stopCodeId); } catch (Exception exc) { result.fault = new FaultTO(exc); } return(result); }
/// <summary> /// Save a ApplicationSession object and it's requests /// </summary> /// <param name="session">The session object to save</param> /// <returns> /// BoolTO.trueOrFalse = true on success /// BoolTO.fault will be != null on error /// </returns> public BoolTO saveSession(ApplicationSession session) { BoolTO result = new BoolTO(); SqlConnection conn = new SqlConnection(); SqlTransaction tx = null; try { conn = getConnection(); tx = conn.BeginTransaction(); SqlDataAdapter adapter = buildInsertSessionAdapter(session, conn, tx); adapter.InsertCommand.ExecuteNonQuery(); foreach (ApplicationRequest request in session.Requests) { adapter = buildInsertRequestAdapter(request, conn, tx); adapter.InsertCommand.ExecuteNonQuery(); } tx.Commit(); result.trueOrFalse = true; return(result); } catch (Exception exc) { if (tx != null && tx.Connection != null) // transaction connection should be null if completed { tx.Rollback(); } result.fault = new FaultTO(exc); return(result); } finally { conn.Close(); if (tx != null) { tx.Dispose(); } } }
public BoolTO getIdProofingStatus(string patientId, string patientName, string patientDOB) { BoolTO result = new BoolTO(); if (mySession == null || mySession.ConnectionSet == null || !mySession.ConnectionSet.IsAuthorized) { result.fault = new FaultTO("Connections not ready for operation", "Need to login?"); } else if (String.IsNullOrEmpty(patientId)) { result.fault = new FaultTO("Must supply patient ID"); } if (result.fault != null) { return(result); } Patient patient = new Patient() { SSN = new SocSecNum(patientId), Name = new PersonName(patientName), DOB = patientDOB }; try { if (SocSecNum.isValid(patientId)) // if ID passed was SSN - turn in to { Patient[] matches = new PatientApi().match(mySession.ConnectionSet.BaseConnection, patient.SSN.toString()); if (matches == null || matches.Length == 0) { result.fault = new FaultTO("No patient found with that SSN!"); return(result); } if (matches.Length > 0) { result.fault = new FaultTO("Duplicate SSN found", "Please contact the system administrator"); return(result); } if (String.IsNullOrEmpty(matches[0].LocalPid)) { result.fault = new FaultTO("Invalid record associated with that SSN", "Please contact the system administrator"); return(result); } PatientTO vistaPatient = new PatientLib(mySession).select(matches[0].LocalPid); patient.LocalPid = matches[0].LocalPid; patient.MpiPid = vistaPatient.mpiPid; } //new AccountLib(mySession).setupMultiSourceQuery("pwd", patient.s mySession.ConnectionSet.setLocalPids(patient.MpiPid); IndexedHashtable ihs = new PatientApi().getIdProofingStatus(mySession.ConnectionSet, patient); if (ihs == null || ihs.Count == 0) { result.trueOrFalse = false; } else { result.trueOrFalse = true; for (int i = 0; i < ihs.Count; i++) // loop through - if any are false, result is false { if (!(bool)ihs.GetValue(i)) { result.trueOrFalse = false; break; } } } } catch (Exception exc) { result.fault = new FaultTO(exc); } finally { try { mySession.ConnectionSet.disconnectAll(); } catch (Exception) { } } return(result); }