public Int64 GetStoreNode(string value) { StoreNodeRequest snr = new StoreNodeRequest(); snr.Value = new StoreNodeParam(); snr.Value.Value = value; snr.Value.ParamOrdinal = 0; snr.Langauge = new StoreNodeParam(); snr.Langauge.Value = null; snr.Langauge.ParamOrdinal = 1; snr.DataType = new StoreNodeParam(); snr.DataType.Value = null; snr.DataType.ParamOrdinal = 2; return this.GetNodeId(snr); }
private Int64 GetNodeId(StoreNodeRequest snr) { System.Web.HttpBrowserCapabilities browser = HttpContext.Current.Request.Browser; if (snr.Value.Value.ToString().Contains(Environment.NewLine) && browser.Browser == "IE") { snr.Value.Value = snr.Value.Value.ToString().Replace(Environment.NewLine, ("\n")); } SessionManagement sm = new SessionManagement(); string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString; SqlConnection dbconnection = new SqlConnection(connstr); SqlParameter[] param = new SqlParameter[snr.Length]; string error = string.Empty; dbconnection.Open(); if (snr.Value != null) param[snr.Value.ParamOrdinal] = new SqlParameter("@value", snr.Value.Value); if (snr.Langauge != null) param[snr.Langauge.ParamOrdinal] = new SqlParameter("@language", null); if (snr.DataType != null) param[snr.DataType.ParamOrdinal] = new SqlParameter("@DataType", null); param[snr.Length - 3] = new SqlParameter("@SessionID", sm.Session().SessionID); param[snr.Length - 2] = new SqlParameter("@Error", null); param[snr.Length - 2].Size = 1; param[snr.Length - 2].DbType = DbType.String; param[snr.Length - 2].Direction = ParameterDirection.Output; param[snr.Length - 1] = new SqlParameter("@NodeID", null); param[snr.Length - 1].DbType = DbType.Int64; param[snr.Length - 1].Direction = ParameterDirection.Output; using (var cmd = GetDBCommand(dbconnection, "[RDF.].GetStoreNode", CommandType.StoredProcedure, CommandBehavior.CloseConnection, param)) { try { //For Output Parameters you need to pass a connection object to the framework so you can close it before reading the output params value. ExecuteSQLDataCommand(cmd); } finally { SqlConnection.ClearPool(dbconnection); cmd.Connection.Close(); cmd.Dispose(); } } return Convert.ToInt64(param[snr.Length - 1].Value.ToString()); }