// I never really understood why the signature did not include the return type, that doesn't make any sense to me. // Shouldn't you be able to overload a function by just the return type? public DataSet runScript(environemnt env, DataTable myInputTable, string script, string appInstance, bool auth = false, string extraParamName = "", string extraParamValue = "") { try { RSSEController rc = new RSSEController(); //script = "TEST_HANDSHAKE"; //appInstance = "GENERAL"; rc.AddParamsEntry("@Script", script); rc.AddParamsEntry("@App", appInstance); rc.AddParamsEntry("@UserName", MainWindow.currentUser); rc.AddParamsEntry("@Environment", @"DEFAULT"); if (extraParamName != "") { rc.AddParamsEntry(extraParamName, extraParamValue); } if (myInputTable != null) { rc.AddInputTable(myInputTable); } string target = "DEV"; if (env == environemnt.TEST) { target = "TEST"; } if (env == environemnt.PROD) { target = "PROD"; } bool authenticate = auth; DataSet ds = rc.CallWS(target, authenticate); if ((ds.Tables.Count >= 1) && ds.Tables[0].TableName.ToUpper() == "ERRORTABLE") { MessageBox.Show("An error has occurred processing the script: " + script + ":" + Environment.NewLine + ds.Tables[0].Rows[0][0].ToString()); return(null); } return(ds); } catch (Exception ex) { string error = "An error has been thrown while processing the script: " + script + ":" + Environment.NewLine + Environment.NewLine + "The error is: " + Environment.NewLine + ex.ToString(); MessageBox.Show(error); return(new DataSet()); } }
// I never really understood why the signature did not include the return type, that doesn't make any sense to me. // Shouldn't you be able to overload a function by just the return type? public DataSet runScript(environemnt env, DataTable myInputTable, string script, string appInstance, bool auth = false, string extraParamName = "", string extraParamValue = "", string epn2 = "", string epv2 = "", string epn3 = "", string epv3 = "", string epn4 = "", string epv4 = "", string epn5 = "", string epv5 = "", string epn6 = "", string epv6 = "") { try { RSSEController rc = new RSSEController(); //script = "TEST_HANDSHAKE"; //appInstance = "GENERAL"; rc.AddParamsEntry("@Script", script); rc.AddParamsEntry("@App", appInstance); rc.AddParamsEntry("@UserName", MainWindow.currentUser); rc.AddParamsEntry("@Environment", @"DEFAULT"); if (extraParamName != "") { rc.AddParamsEntry(extraParamName, extraParamValue); } if (epn2 != "") { rc.AddParamsEntry(epn2, epv2); } if (epn3 != "") { rc.AddParamsEntry(epn3, epv3); } if (epn4 != "") { rc.AddParamsEntry(epn4, epv4); } if (epn5 != "") { rc.AddParamsEntry(epn5, epv5); } if (epn6 != "") { rc.AddParamsEntry(epn6, epv6); } if (myInputTable != null) { rc.AddInputTable(myInputTable); } string target = "DEV"; if (env == environemnt.TEST) { target = "TEST"; } if (env == environemnt.PROD) { target = "PROD"; } bool authenticate = auth; DataSet ds = rc.CallWS(target, authenticate); if ((ds.Tables.Count >= 1) && ds.Tables[0].TableName.ToUpper() == "ERRORTABLE") { if (ds.Tables[0].Rows[0]["SE_CustomErrorCode"].ToString().Contains("login failed")) { string message = ds.Tables[0].Rows[0]["SE_CustomErrorCode"].ToString(); string username = ""; string database = ""; int apostrophe = message.IndexOf("'"); if (apostrophe > 0) { username = message.Substring(apostrophe + 1); int closingapostrophe = username.IndexOf("'"); if (closingapostrophe > 1) { username = username.Substring(0, closingapostrophe); } } int datasource = message.IndexOf("Data Source"); if (datasource > 1) { database = message.Substring(datasource); } MessageBox.Show("Please submit a DBA ServiceDesk ticket requesting the login:"******"Be added to the database:" + Environment.NewLine + database, "The database permissions have been lost"); } MessageBox.Show("An error has occurred processing the script: " + script + ":" + Environment.NewLine + ds.Tables[0].Rows[0][0].ToString()); return(null); } return(ds); } catch (Exception ex) { string error = "An error has been thrown while processing the script: " + script + ":" + Environment.NewLine + Environment.NewLine + "The error is: " + Environment.NewLine + ex.ToString(); MessageBox.Show(error); return(new DataSet()); } }
public bool executeScript(environemnt env, DataTable myInputTable, string script, string appInstance, bool auth = false, string extraParamName = "", string extraParamValue = "", string epn2 = "", string epv2 = "", string epn3 = "", string epv3 = "", string epn4 = "", string epv4 = "", string epn5 = "", string epv5 = "", string epn6 = "", string epv6 = "") { try { RSSEController rc = new RSSEController(); //script = "TEST_HANDSHAKE"; //appInstance = "GENERAL"; rc.AddParamsEntry("@Script", script); rc.AddParamsEntry("@App", appInstance); rc.AddParamsEntry("@UserName", MainWindow.currentUser); rc.AddParamsEntry("@Environment", @"DEFAULT"); if (extraParamName != "") { rc.AddParamsEntry(extraParamName, extraParamValue); } if (epn2 != "") { rc.AddParamsEntry(epn2, epv2); } if (epn3 != "") { rc.AddParamsEntry(epn3, epv3); } if (epn4 != "") { rc.AddParamsEntry(epn4, epv4); } if (epn5 != "") { rc.AddParamsEntry(epn5, epv5); } if (epn6 != "") { rc.AddParamsEntry(epn6, epv6); } if (myInputTable != null) { rc.AddInputTable(myInputTable); } string target = "DEV"; if (env == environemnt.TEST) { target = "TEST"; } if (env == environemnt.PROD) { target = "PROD"; } bool authenticate = auth; DataSet ds = rc.CallWS(target, authenticate); return(true); } catch (Exception ex) { string error = "An error has been thrown while processing the script: " + script + ":" + Environment.NewLine + Environment.NewLine + "The error is: " + Environment.NewLine + ex.ToString(); MessageBox.Show(error); return(false); } }