public SQLResult Get(string category, string name, string profile = null, int timeOut = 0, bool columnInfo = false , string p0 = null, string p1 = null, string p2 = null, string p3 = null, string p4 = null , string p5 = null, string p6 = null, string p7 = null, string p8 = null, string p9 = null) { try { if (!SAPB1.brokerConf.uq) { throw new Exception("User Query module was disabled in web.config for SQL Broker"); } if (string.IsNullOrEmpty(name)) { throw new Exception("No name was defined for User Query"); } SQLQuery q = new SQLQuery { userQuery = name, columnInfo = columnInfo, uqCategory = category }; if (!string.IsNullOrEmpty(profile)) { q.connection = new ConnectionParams { Profile = profile } } ; q.timeOut = timeOut; q.parameters = new string[10]; q.parameters[0] = p0; q.parameters[1] = p1; q.parameters[2] = p2; q.parameters[3] = p3; q.parameters[4] = p4; q.parameters[5] = p5; q.parameters[6] = p6; q.parameters[7] = p7; q.parameters[8] = p8; q.parameters[9] = p9; checkSQLReqParameter(q); return(SAPB1.SQLQuery(q, true, new SQLResult(Request))); } catch (Exception e) { return(handleException(e)); } }
public BOResult Post([FromBody] BORequest boReq, string name) { try { checkBoReqParameter(boReq); return(SAPB1.BORequest(q: boReq, name: name, id: null, post: true, result: new BOResult(Request))); } catch (Exception e) { return(handleException(e)); } }
public BOResult Put([FromBody] BORequest boReq, string name, string id, string profile = null) { try { checkBoReqParameter(boReq); applyProfileFromURI(boReq, profile); return(SAPB1.BORequest(q: boReq, name: name, id: id, put: true, result: new BOResult(Request))); } catch (Exception e) { return(handleException(e)); } }
public SQLResult Get([FromBody] SQLQuery value) { try { if (!SAPB1.brokerConf.sql) { throw new Exception("SQL module was disabled in web.config for SQL Broker"); } checkSQLReqParameter(value); return(SAPB1.SQLQuery(value, true, new SQLResult(Request))); } catch (Exception e) { return(handleException(e)); } }
public BOResult Get(/*[FromBody]BORequest boReq,*/ string name, string id, string profile = null, bool rawXml = false, bool xmlSchema = false) { try { BORequest boReq = new BORequest { connection = new ConnectionParams { Profile = profile } }; applyProfileFromURI(boReq, profile, rawXml, xmlSchema); checkBoReqParameter(boReq); return(SAPB1.BORequest(q: boReq, name: name, id: id, result: new BOResult(Request))); } catch (Exception e) { return(handleException(e)); } }
public BOResult Delete(/*BORequest boReq,*/ string name, string id, string profile = null) { try { //checkBoReqParameter(boReq); BORequest boReq = new BORequest { connection = new ConnectionParams { Profile = profile } }; applyProfileFromURI(boReq, profile); return(SAPB1.BORequest(q: boReq, name: name, id: id, delete: true, result: new BOResult(Request))); } catch (Exception e) { return(handleException(e)); } }
public MultiResult Post([FromBody] MultiRequest mr, string profile = null) { MultiResult result = new MultiResult(Request); try { if (mr == null) { throw new Exception("The body is missing or not formatted correctly. Maybe just a comma is missing between two attributes."); } //Apply profile from URI if (!string.IsNullOrEmpty(profile)) { if (mr.connection == null) { mr.connection = new ConnectionParams { Profile = profile } } ; else if (string.IsNullOrEmpty(mr.connection.Profile)) { mr.connection.Profile = profile; } } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); var cp = SAPB1.getEffectiveConnectionParams(mr?.connection, ref result.connection); //START Transaction with using and pass the same transaction object to each request processor using (var t = DIConnection.startTransaction(cp)) { //Must be used with using !!! MReqResult reqResult = null; try { result.totalJobsRequested = mr.requests.Count; for (int i = 0; i < mr.requests.Count; i++) { result.index = i; MReqJob mrJob = mr.requests[i]; reqResult = new MReqResult(); if (!string.IsNullOrEmpty(mrJob.boName) || mrJob.boReq != null) { //result.reqJob = mrJob; bool post = false; bool delete = false; bool put = false; bool getReq = false; if (string.IsNullOrEmpty(mrJob.reqType)) { throw new SQLBrokerError($"Multi-Request BO job {mrJob.boName} has no reqType property (GET, PUT, DELETE, POST)"); } else { switch (mrJob.reqType) { case "GET": getReq = true; break; case "POST": post = true; break; case "PUT": put = true; break; case "DELETE": delete = true; break; default: { throw new SQLBrokerError($"Multi-Request BO job {mrJob.boName} reqType {mrJob.reqType} is invalid. Use GET, PUT, DELETE, POST"); } } } if (mrJob.boReq == null) { if (getReq || delete) { mrJob.boReq = new BORequest { connection = new ConnectionParams { Profile = profile } }; } else { throw new SQLBrokerError($"Multi-Request BO job {mrJob.boName} no boReq object defined for PUT, POST"); } } if (string.IsNullOrEmpty(mrJob.boName)) { throw new SQLBrokerError("Multi-request BO job has no boName property"); } if (string.IsNullOrEmpty(mrJob.boId)) { if (getReq || put || delete) { throw new SQLBrokerError($"Multi-Request BO job {mrJob.boName} reqType {mrJob.reqType} requires non-empty boId property."); } } else { if (post) { throw new SQLBrokerError($"Multi-Request BO job {mrJob.boName} reqType {mrJob.reqType} doesn't allow boId property. Delete boId from your request."); } } reqResult.boResult = new BOResult(Request); reqResult.boResult.connection = new NoPwdConnectionParams(cp); reqResult.boResult.jobNumber = i; SAPB1.BOJob(t, q: mrJob.boReq, name: mrJob.boName, id: mrJob.boId, post: post, delete: delete, put: put, result: reqResult.boResult); } if (mrJob.sqlReq != null) { throw new SQLBrokerError($"Multi-Request SQL is not supported currently. Stay tuned, however."); //var sqlResult = SAPB1.SQLQuery(value, false, new SQLResult(Request)); } result.results.Add(reqResult); } t.Commit(); sw.Stop(); result.execMillis = (int)sw.Elapsed.TotalMilliseconds; return(result); } catch (Exception) { result.errorResult = reqResult; //ROLLBACK Transaction, if not rolled back alreadt t.Rollback(); throw; } } //COMMIT the transacyion if no errors occured } catch (Exception e) { if (e is SQLBrokerError) { SQLBrokerError brokerError = e as SQLBrokerError; if (result.errorResult == null) { result.errorResult = new MReqResult(); } result.errorResult.boResult = brokerError.boResult; result.errorResult.sqlResult = brokerError.sqlResult; } return(result.setResponseStatus(HttpStatusCode.BadRequest, e)); } }