/// <summary> /// 根据参数查询RFC数据 /// </summary> /// <param name="refStr">查询返回信息</param> /// <param name="ConnectionSAP">链接信息</param> /// <param name="interfaceFunName">接口名称</param> /// <param name="lnName">料号</param> /// <returns></returns> public ReturnResult Get_RFC_Info_By_Param(ref string refStr, R3Connection ConnectionSAP, string interfaceFunName, string lnName) { ReturnResult result = new ReturnResult(); RFCFunction function = null; try { RFCTableColumnCollection ff = new RFCTableColumnCollection(); function = ConnectionSAP.CreateFunction(interfaceFunName); function.Exports["MATNR"].ParamValue = lnName; //查询条件(料号?) function.Execute(); refStr = function.Imports["NORMT"].ParamValue.ToString().Trim(); //返回数据 ConnectionSAP.Close(); result.Status = true; result.Message = "OK"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message; this.logHandler.Error(MethodBase.GetCurrentMethod().Name, "Call Get_RFC_Info_By_Param Fail: " + ex.Message); } return(result); }
private static void ExecuteSAPQuery(R3Connection con) { using (con) { con.Open(false); // Create Query object Query q; Query q; try { q = con.CreateQuery(WorkSpace.GlobalArea, "/SAPQUERY/QD", "CONNECTIONS_02"); //q.Variant = "ALL"; q.MaxRows = 1000; } catch (Exception e1) { Console.WriteLine(e1.ToString()); return; } // Add a criteria (in this case the material number) //q.SelectionParameters["SP$00017"].Ranges.Add(Sign.Include, RangeOption.Equals, "100-100"); // Add a second criteria (in this case the currency) //q.SelectionParameters["S_WAERS"].Ranges.Add(Sign.Include, RangeOption.Equals, "EUR"); // Run the Query q.Execute(); // Bind result to datagrid DataTable table = q.Result; Console.Read(); } }
public void SsoR3Connection(SapSsoToken sapSsoToken) { R3Connection r3Connection; try { r3Connection = new R3Connection(); r3Connection.Client = sapConfig.SapClient; r3Connection.Host = sapConfig.SapHost; r3Connection.SystemNumber = sapConfig.SapSystemNumber; r3Connection.LogonGroup = sapConfig.SapLogonGroup; r3Connection.Language = sapConfig.SapLanguage; r3Connection.MessageServer = sapConfig.SapMessageServer; r3Connection.Protocol = sapConfig.SapProtocol; r3Connection.SID = sapConfig.SapSid; r3Connection.UsesLoadBalancing = sapConfig.SapUsesLoadBalancing; r3Connection.OpenSSO(sapSsoToken.SsoToken, sapConfig.SapUsesLoadBalancing); } catch (Exception exception) { r3Connection = null; Log.Error(exception, "Could not create R3Connection object"); } }
public void MakeCookieConnection(bool impersonate) { try { // Get SSO Ticket string ssoTicket = GetCookieTicket(impersonate); Log.Information("ssoTicket retrieved successfully."); r3Connection = new R3Connection(); r3Connection.Client = sapConfig.SapClient; r3Connection.Host = sapConfig.SapHost; r3Connection.SystemNumber = sapConfig.SapSystemNumber; r3Connection.LogonGroup = sapConfig.SapLogonGroup; r3Connection.Language = sapConfig.SapLanguage; r3Connection.MessageServer = sapConfig.SapMessageServer; r3Connection.Protocol = sapConfig.SapProtocol; r3Connection.SID = sapConfig.SapSid; r3Connection.UsesLoadBalancing = sapConfig.SapUsesLoadBalancing; Log.Information("Trying to Connect User - " + WindowsIdentity.GetCurrent().Name + " to SAP Using SSO Credentials"); r3Connection.OpenSSO(ssoTicket, sapConfig.SapUsesLoadBalancing); } catch (Exception exception) { r3Connection = null; Log.Error(exception, "Could not create R3Connection object using Cookie Request"); } }
/// <summary> /// 根据RFC配置信息,打开RFC链接 /// </summary> /// <param name="Connection"></param> /// <returns></returns> public ReturnResult ERGetPConnection(ERPGetConnection Connection) { ReturnResult consap = new ReturnResult(); R3Connection ConnectionSAP = new R3Connection(); try { string connString = BuildConneciton(Connection); ConnectionSAP = new R3Connection(connString); if (!ConnectionSAP.Ping()) { ConnectionSAP.Open(); consap.Status = true; } } catch (Exception ex) { ConnectionSAP.Close(); consap.Message = ex.Message; consap.Status = false; this.logHandler.Error(MethodBase.GetCurrentMethod().Name, "Call ERGetPConnection Fail: " + ex.Message); } consap.Anything = ConnectionSAP; return(consap); }
public void MakeNonSsoConnection() { try { r3Connection = new R3Connection(); r3Connection.Client = sapConfig.SapClient; r3Connection.Host = sapConfig.SapHost; r3Connection.SystemNumber = sapConfig.SapSystemNumber; r3Connection.UserName = sapConfig.SapNonSsoUserName; r3Connection.Password = sapConfig.SapNonSsoPassword; r3Connection.LogonGroup = sapConfig.SapLogonGroup; r3Connection.Language = sapConfig.SapLanguage; r3Connection.MessageServer = sapConfig.SapMessageServer; r3Connection.Protocol = sapConfig.SapProtocol; r3Connection.SID = sapConfig.SapSid; r3Connection.UsesLoadBalancing = sapConfig.SapUsesLoadBalancing; Log.Information("Trying to Connect User - " + WindowsIdentity.GetCurrent().Name + " to SAP using NON SSO"); r3Connection.Open(); } catch (Exception exception) { r3Connection = null; Log.Error("SAP Error " + exception, "Could not create R3Connection"); } }
private static void RFCUserCreate(R3Connection con, string username) { using (con) { con.Open(false); RFCFunction func = con.CreateFunction("BAPI_USER_CREATE1"); func.Exports["USERNAME"].ParamValue = username; func.Exports["GENERATE_PWD"].ParamValue = "X"; RFCStructure ADDRESS = func.Exports["ADDRESS"].ToStructure(); ADDRESS["FIRSTNAME"] = "FistName"; ADDRESS["LASTNAME"] = "LastName"; RFCStructure PASSWORD = func.Exports["PASSWORD"].ToStructure(); PASSWORD["BAPIPWD"] = "init01"; func.Execute(); RFCStructure pw = func.Imports["GENERATED_PASSWORD"].ToStructure(); string passw = pw["BAPIPWD"].ToString(); Console.WriteLine("Password:"******"RETURN"][0, "MESSAGE"].ToString(); Console.WriteLine(message); Console.ReadLine(); con.Close(); } }
/// <summary> /// RFCs the function initialize. /// </summary> /// <param name="conn">The connection.</param> /// <param name="rfcName">Name of the RFC.</param> /// <returns>RFCFunction.</returns> public static RFCFunction RFCFunctionInit(this R3Connection conn, string rfcName) { var fun = conn.CreateFunction(rfcName); var tbs = fun.Tables; return(fun); }
/// <summary> /// 查询RFC数据(无查询参数) /// </summary> /// <param name="ConnectionSAP">链接信息</param> /// <param name="interfaceFunName">接口名称</param> /// <returns></returns> public ReturnResult Get_RFC_Info_By_NoParam(ref DataTable dataTable_put, R3Connection ConnectionSAP, string interfaceFunName) { RFCTable rfcTable_ERR = new RFCTable(); ReturnResult result = new ReturnResult(); RFCFunction function = null; try { function = ConnectionSAP.CreateFunction(interfaceFunName); function.Execute(); rfcTable_ERR = function.Tables["T_OUTTAB"];//out table dataTable_put = rfcTable_ERR.ToADOTable(); ConnectionSAP.Close(); result.Status = true; result.Message = "OK"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message; this.logHandler.Error(MethodBase.GetCurrentMethod().Name, "Call Get_RFC_Info_By_NoParam Fail: " + ex.Message); } return(result); }
static void Main(string[] args) { string mypath = AppDomain.CurrentDomain.BaseDirectory; string myfile = mypath + "DSOInput.csv"; string res; try { ERPConnect.LIC.SetLic("17YZYZ5VVZ"); string[] myLines = System.IO.File.ReadAllLines(myfile); string dsoname = "ZKEDSO01"; // ZBOARD01 R3Connection con = new R3Connection("bw2.theobald-software.com", 0, "Demouser1", "Board2016", "DE", "800"); con.Open(); RFCFunction delfunc = con.CreateFunction("RSDRI_ODSO_DELETE_RFC"); delfunc.Exports["I_DELETE_ALL"].ParamValue = "X"; delfunc.Exports["I_ODSOBJECT"].ParamValue = dsoname; delfunc.Execute(); RFCFunction insfunc = con.CreateFunction("RSDRI_ODSO_INSERT_RFC"); insfunc.Exports["I_ODSOBJECT"].ParamValue = dsoname; foreach (string myline in myLines) { if (!myline.StartsWith("Item")) { string[] vals = myline.Split(",".ToCharArray()); if (vals.Length >= 4) { string st = string.Empty; st += vals[1].PadRight(10); // Customer 10 st += vals[2].PadRight(18); // Material 18 st += vals[3].PadRight(8); // Date 8 RFCStructure neworw = insfunc.Tables["I_T_DATA"].Rows.Add(); neworw["DATA"] = st; } } } insfunc.Execute(); int num = (int)insfunc.Imports["E_NUMROWS"].ParamValue; res = num + " rows inserted into DSO " + dsoname; } catch (Exception e1) { System.IO.File.WriteAllText(mypath + "UploadLog.txt", e1.ToString()); return; } System.IO.File.WriteAllText(mypath + "UploadLog.txt", res); }
public static void Set(ref R3Connection con) { con.UserName = "******"; con.Password = "******"; con.Language = "EN"; con.Client = "800"; con.Host = "ec5.theobald-software.com"; con.SystemNumber = 0; //con.Protocol = ClientProtocol.NWRFC; // Optional: If the NW RFC libraries are used. }
public async Task <string> GetMoneda() { await Task.FromResult(0); var mensaje = string.Empty; var trans = new Transaction(); var r3Connection1 = new R3Connection(_sapConnectionString); trans.Connection = r3Connection1; trans.TCode = "PA30"; trans.AddStepSetNewDynpro("SAPMP50A", "1000"); trans.AddStepSetOKCode("=INS"); trans.AddStepSetField("RP50G-PERNR", "20007955"); trans.AddStepSetField("BDC_SUBSCR", "SAPMP50A 0800SUBSCR_HEADER"); trans.AddStepSetField("BDC_SUBSCR", "SAPMP50A 0320SUBSCR_ITMENU"); trans.AddStepSetField("BDC_SUBSCR", "SAPMP50A 0330SUBSCR_TIME"); trans.AddStepSetField("RP50G-TIMR6", "X"); trans.AddStepSetField("RP50G-BEGDA", DateTime.Now.ToString("dd.MM.yyyy")); trans.AddStepSetField("RP50G-ENDDA", DateTime.Now.ToString("dd.MM.yyyy")); trans.AddStepSetField("BDC_SUBSCR", "SAPMP50A 0350SUBSCR_ITKEYS"); trans.AddStepSetCursor("RP50G-SUBTY"); trans.AddStepSetField("RP50G-CHOIC", "2001"); trans.AddStepSetField("RP50G-SUBTY", "1013"); trans.AddStepSetNewDynpro("MP200000", "2000"); trans.AddStepSetCursor("P2001-BEGDA"); trans.AddStepSetOKCode("=UPD"); trans.AddStepSetField("P2001-BEGDA", DateTime.Now.ToString("dd.MM.yyyy")); trans.AddStepSetField("P2001-ENDDA", DateTime.Now.ToString("dd.MM.yyyy")); trans.Connection.Open(false); trans.Execute(); if (trans.Returns != null && trans.Returns.Count > 0) { foreach (BatchReturn item in trans.Returns) { if (item.MessageID == "PG" && item.MessageNumber == "102") { mensaje = "OK"; break; } else { mensaje = mensaje + "|" + item.Message; } } } return(mensaje); }
public BusinessSAP() { string User = ConfigurationManager.AppSettings["User"].ToString(); string AppServerHost = ConfigurationManager.AppSettings["AppServerHost"].ToString(); int SystemNumber = Convert.ToInt32(ConfigurationManager.AppSettings["SystemNumber"].ToString()); string Password = Encriptador.Desencriptar(ConfigurationManager.AppSettings["Password"].ToString(), true); string Client = ConfigurationManager.AppSettings["Client"].ToString(); string Language = ConfigurationManager.AppSettings["Language"].ToString(); string Licencia = ConfigurationManager.AppSettings["Licencia"].ToString(); LIC.SetLic(Licencia); ConectorSAP = new R3Connection(AppServerHost, SystemNumber, User, Password, Language, Client); }
private static void SendIDoc(R3Connection con, string matname, bool async) { using (con) { con.Open(false); ERPConnect.Idocs.Idoc id = con.CreateEmptyIdoc("MATMAS05", ""); id.SNDPRN = "ERPTEST"; id.SNDPRT = "LS"; id.SNDPOR = "ERPTEST"; id.RCVPRN = "BW_STDCLNT"; id.RCVPRT = "LS"; id.MESTYP = "MATMAS"; // Idoc Segement E1MARAM ERPConnect.Idocs.IdocSegment e1maram = id.CreateSegment("E1MARAM"); e1maram.Fields["MATNR"].FieldValue = matname; e1maram.Fields["MTART"].FieldValue = "FERT"; e1maram.Fields["MEINS"].FieldValue = "PCE"; e1maram.Fields["MBRSH"].FieldValue = "M"; e1maram.Fields["BRGEW"].FieldValue = "1"; e1maram.Fields["NTGEW"].FieldValue = "1"; e1maram.Fields["GEWEI"].FieldValue = "KG"; id.Segments.Add(e1maram); // Idoc Segement E1MAKTM ERPConnect.Idocs.IdocSegment e1maktm = id.CreateSegment("E1MAKTM"); e1maktm.Fields["SPRAS"].FieldValue = "E"; e1maktm.Fields["MAKTX"].FieldValue = "my Article"; e1maram.ChildSegments.Add(e1maktm); if (async) { id.SendAndWait(); IdocStatus status = id.GetCurrentStatus(); Console.WriteLine(status.Status + "-> " + status.Description); } else { id.Send(); Console.WriteLine("IDoc sent"); } con.Close(); Console.ReadLine(); } }
static void Main(string[] args) { // Initialisation ERPConnect.LIC.SetLic("VYY2ZZ81ZZ"); // i - 9156ae16 //R3Connection con = new R3Connection("52.7.193.1", 00, "BPINST", "Welcome1", "en", "100"); // ERP, Client 100 R3Connection con = new R3Connection("vhcals4hci.dummy.nodomain", 00, "Babi", "Welcome100", "en", "100"); con.Protocol = ClientProtocol.NWRFC; // BW, Client 200 R3Connection bwcon = new R3Connection("vhcals4hci.dummy.nodomain", 00, "BPINST", "Welcome1", "en", "200"); //R3Connection bwcon = new R3Connection("vhcals4hci.dummy.nodomain", 00, "Babi", "Welcome2", "en", "200"); bwcon.Protocol = ClientProtocol.NWRFC; // RFC //RFCUserCreate(con, "BTEST06"); // BAPI //BapiGetFlightList(con); // Query CONNECTIONS_02 ALL //ExecuteSAPQuery(con); // Send Idoc (synchron) // async = true //SendIDoc(con, "TESTMAT13",true); // async = false //SendIDoc(con, "TESTMAT14", false); //Start RFC Server to Add //StartRFCServer(); // Receive IDoc // TA BD10 in SAP: // Material: TESTMAT, Message Type: MATMAS, LogicalSystem: ERPTEST // /nrz11 gw/acl_mode = 1 -> set to 0 //StartIDocServer(); // BW Cube (MDX) // $0D_NW_C01 GetBWCube(bwcon, "$0D_NW_C01"); }
static void Main(string[] args) { using (R3Connection con = new R3Connection()) { con.Host = "saperp.theobald.local"; con.SystemNumber = 0; con.Client = "800"; con.Language = "DE"; con.SNCSettings.Enabled = true; con.SNCSettings.PartnerName = "p:[email protected]"; con.SNCSettings.Mechanism = SNCMechanism.Kerberos5; con.SNCSettings.QualityOfProtection = SNCQualityOfProtection.Maximum; con.Open(); // do something with con Console.WriteLine("SSO Connection Succesful!"); } }
private static void GetBWCube(R3Connection con, string name) { using (con) { con.Open(false); //0,0D_NW_CHANN,Distribution Channel, C,255,0 //1,0D_NW_CNTRY,Country,C,255,0 //2,0D_NW_CODE,Company code, C,255,0 //3,0D_NW_DIV,Division,C,255,0 //4,0D_NW_PAYER,Payer,C,255,0 //5,0D_NW_PLANT,Plant,C,255,0 //6,0D_NW_PROD,Product,C,255,0 //7,0D_NW_REGIO,Region,C,255,0 //8,0D_NW_SGRP,Sales Group, C,255,0 //9,0D_NW_SHIP,Ship - to Party,C,255,0 //10, 0D_NW_SOLD,Sold - to Party,C,255,0 //11, 0D_NW_SORG,Sales Organization, C,255,0 //12, 0CALYEAR,Calendar Year, C,255,0 //13, 0MEASURES0000000000000009_0D9NW9NETV000000000000010,Net Value stat curr, P,16,0 //14, 0MEASURES0000000000000009_0D9NW9OORV000000000000010,Open order stat curr, P,16,0 BWCube query = con.CreateBWCube(name); query.Dimensions["0D_NW_CHANN"].SelectForFlatMDX = true; query.Dimensions["0D_NW_CNTRY"].SelectForFlatMDX = true; query.Dimensions["0D_NW_CODE"].SelectForFlatMDX = true; query.Dimensions["0D_NW_DIV"].SelectForFlatMDX = true; query.Dimensions["0D_NW_PAYER"].SelectForFlatMDX = true; query.Dimensions["0D_NW_PLANT"].SelectForFlatMDX = true; query.Measures[0].SelectForFlatMDX = true; query.Measures[1].SelectForFlatMDX = true; query.Measures[2].SelectForFlatMDX = true; query.Measures[3].SelectForFlatMDX = true; //query.Variables["MAT01"].SingleRange.LowValue = this.txtMatNr.Text; DataTable table = query.Execute(); Console.Read(); } }
private static void BapiGetFlightList(R3Connection con) { using (con) { con.Open(false); BusinessObjectMethod func = con.CreateBapi("Flight", "GetList"); func.Exports["Airline"].ParamValue = "AA"; func.Execute(); DataTable table = func.Tables["FLIGHT_LIST"].ToADOTable(); con.Close(); Console.ReadLine(); } }
static void Main(string[] args) { R3Connection con = new R3Connection(); try { SAPConnection.Set(ref con); //con.UseGui = true; con.Open(false); //SAPTransaction.executeMM02(con); SAPTransaction.executeXD02(con); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); throw ex; } finally { con.Close(); } }
/// <summary> /// 根据参数查询RFC数据 /// </summary> /// <param name="refStr">查询返回信息</param> /// <param name="ConnectionSAP">链接信息</param> /// <param name="interfaceFunName">接口名称</param> /// <param name="tbParam">料号</param> /// <returns></returns> public ReturnResult Get_RFC_Info_By_Param(ref string rfcRes, R3Connection ConnectionSAP, string interfaceFunName, DataTable tbParam) { RFCTable rfcTable_ERR = new RFCTable(); ReturnResult result = new ReturnResult(); RFCFunction function = null; try { RFCTableColumnCollection ff = new RFCTableColumnCollection(); function = ConnectionSAP.CreateFunction(interfaceFunName); RFCTable info_table_H = function.Tables["IT_ZPPT6017"];//in table foreach (DataRow row in tbParam.Rows) { RFCStructure rfcStruc_H = info_table_H.AddRow(); rfcStruc_H["AUFNR"] = row[0]; //MO 编号 rfcStruc_H["MO_NO"] = row[1]; //MO 排序 } function.Execute(); //rfcTable_ERR = function.Tables["IT_ZPPT6017"];//out table //dataTable_put = rfcTable_ERR.ToADOTable(); rfcRes = function.Imports["E_FLAG"].ParamValue.ToString().Trim(); ConnectionSAP.Close(); result.Status = true; result.Message = "OK"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message; this.logHandler.Error(MethodBase.GetCurrentMethod().Name, "Call Get_RFC_Info_By_Param Fail: " + ex.Message); } return(result); }
public EmployeeDetail getEmployeeDetailedInfo(string personalNr) { EmployeeDetail result = null; if (!personalNr.Equals(string.Empty)) { var connection = new R3Connection(_configManager.getConnectionString()); try { connection.Open(); var function = connection.CreateFunction(Constants.BAPI_PERSDATA_GETDETAILEDLIST); function.Exports[Constants.EMPLOYEENUMBER].ParamValue = personalNr; function.Execute(); var table = function.Tables[Constants.PERSONALDATA]; if (table != null || table.Rows.Count > 0) { foreach (RFCStructure row in table.Rows) { var NAMeOFFORMOFADD = (string)row[Constants.NAMeOFFORMOFADD]; var FIRSTNAME = (string)row[Constants.FIRSTNAME]; var LASTNAME = (string)row[Constants.LASTNAME]; var NAMEOFLANGUAGE = (string)row[Constants.NAMEOFLANGUAGE]; var NAMEOFNATIONALI = (string)row[Constants.NAMEOFNATIONALITY]; var DATEOFBIRTH = (string)row[Constants.DATEOFBIRTH]; var BIRTHPLACE = (string)row[Constants.BIRTHPLACE]; var NAMEOFGENDER = (string)row[Constants.NAMEOFGENDER]; var NAMEOFCOUNTRYOF = (string)row[Constants.NAMEOFCOUNTRYOF]; result = new EmployeeDetail() { Country = NAMEOFCOUNTRYOF, DateOfBith = DATEOFBIRTH, FirstName = FIRSTNAME, Gender = NAMEOFGENDER, Language = NAMEOFLANGUAGE, LastName = LASTNAME, NamePrefix = NAMeOFFORMOFADD, Nationality = NAMEOFNATIONALI, PlaceOfBith = BIRTHPLACE }; } } } catch (Exception ex) { _loggingManager.ThrowException(ex, DOTNETSAPErrorSeverity.High); } finally { if (connection != null && connection.Ping()) { connection.Close(); } } } return(result); }
public void CreateConnection(string connectionString) { Connection = new R3Connection(connectionString); Connection.ParseConnectionString(connectionString); }
public List <EmployeeBasic> getEmployeeBasicList(string surname, string lastname, string job, string organisation) { string surnameSearch = surname.Equals(string.Empty) ? "*" : surname; string lastnameSearch = lastname.Equals(string.Empty) ? "*" : lastname; string jobSearch = job.Equals(string.Empty) ? "*" : job; string organisationSearch = organisation.Equals(string.Empty) ? "*" : organisation; List <EmployeeBasic> result = new List <EmployeeBasic>(); var connection = new R3Connection(_configManager.getConnectionString()); try { connection.Open(); var function = connection.CreateFunction(Constants.BAPI_EMPLOYEE_GETLIST); function.Exports[Constants.SEARCH_DATE].ParamValue = DateTime.Now.ToShortDateString(); function.Exports[Constants.JOB_SEARK].ParamValue = jobSearch; function.Exports[Constants.JOB_SEARK].ParamValue = jobSearch; function.Exports[Constants.ORG_SEARK].ParamValue = organisationSearch; function.Exports[Constants.SUR_NAME_SEARK].ParamValue = surnameSearch; function.Exports[Constants.LST_NAME_SEARK].ParamValue = lastnameSearch; function.Execute(); var table = function.Tables[Constants.EMPLOYEE_LIST]; if (table != null && table.Rows.Count > 0) { foreach (RFCStructure row in table.Rows) { var PERNR = (string)row[Constants.PERNR]; var ENAME = (string)row[Constants.ENAME]; var ORG_ID = (string)row[Constants.ORG_ID]; var ORG_TEXT = (string)row[Constants.ORG_TEXT]; var JOB_ID = (string)row[Constants.JOB_ID]; var JOB_TEXT = (string)row[Constants.JOB_TEXT]; EmployeeBasic empBasic = new EmployeeBasic() { Name = ENAME, JobID = JOB_ID, JobName = JOB_TEXT, OrganisationID = ORG_TEXT, OrganisationName = ORG_TEXT, PersonalNumber = PERNR }; result.Add(empBasic); } } } catch (Exception ex) { _loggingManager.ThrowException(ex, DOTNETSAPErrorSeverity.High); } finally { if (connection != null && connection.Ping()) { connection.Close(); } } return(result); }