public ActionResult Index( string flowName, string originalName, string connectionName, Dictionary <string, object> model) { var queryLibrary = new QueryLibrary(Request.PhysicalApplicationPath); var queries = queryLibrary.GetQueriesForFlowName(flowName); var query = queries .FirstOrDefault(q => q.OriginalName.Trim().ToLower() == originalName.Trim().ToLower()); if (query == null) { return(new HttpStatusCodeResult(400, "No such query")); } // Get params from model + query var parametersBuilder = new SqlParametersBuilder(); var sqlParameters = parametersBuilder.PopulateSqlParameters(query, model); // Build a DataLayer var connLibrary = new ConnectionLibrary(); if (!connLibrary.HasConnectionWithName(connectionName)) { return(new HttpStatusCodeResult(400, "No such connection")); } var dataLayer = new DataLayer(connectionName); var resultsTable = dataLayer.GetResults(query, sqlParameters); return(Json(resultsTable)); }
// GET: Environments public ActionResult Index() { var library = new ConnectionLibrary(); var result = library.GetConnections(); return(Json(result, JsonRequestBehavior.AllowGet)); }
static IPCS getIPCS() { IPCS ipcs = null; try { ipcs = (IPCS)Activator.GetObject(typeof(IPCS), ConnectionLibrary.buildPCSURL()); } catch (Exception) { Console.WriteLine("Couldn't find IPS."); } return(ipcs); }
public void ConnectionLibrary_IgnoresLocalSqlConnection() { var dummy = new ConnectionStringSettingsCollection(); dummy.Add(ConnectionFakes.GetLocalSqlServer()); dummy.Add(ConnectionFakes.GetFake()); var target = new ConnectionLibrary(dummy); var result = target.GetConnections(); Assert.AreEqual(1, result.Count); CollectionAssert.AllItemsAreNotNull(result); Assert.AreEqual(ConnectionFakes.Name, result.FirstOrDefault().Name); }
public ActionResult Index() { // TODO Dependency Injection var queryLibrary = new QueryLibrary(Request.PhysicalApplicationPath); var flows = queryLibrary.GetQueryFlows(); var environmentLibrary = new ConnectionLibrary(); var envs = environmentLibrary.GetConnections(); var vm = new SherlockViewModel() { Environments = envs, Flows = flows }; return(Json(vm, JsonRequestBehavior.AllowGet)); }
public void LoadConnectionLibrary(ConnectionLibrary library) { _bs.DataSource = library.Connections; if (!DesignMode) { lstConnections.DisplayMember = "ConnectionName"; lstConnections.DataSource = _bs; txtName.DataBindings.Add("Text", _bs, "ConnectionName"); cmbDatabase.DataBindings.Add("Text", _bs, "Database"); txtPassword.DataBindings.Add("Text", _bs, "Password"); txtUrl.DataBindings.Add("Text", _bs, "Url"); txtUser.DataBindings.Add("Text", _bs, "UserName"); if (lstConnections.Items.Count > 0 && !this.MultiSelect) { lstConnections.SetItemSelected(0, true); } } }
public static String FormatCriteria(String fieldName, Object fieldValue, Operators eO, String tableName, Type sysType, ConnectionLibrary eCl) { String criteria = String.Empty; String value; String strOperator = AryOperator[Convert.ToInt32(eO)]; try { if (fieldName.Trim().Length > 0 && fieldValue != null) { if (eCl == ConnectionLibrary.SQlClient) { if (sysType == typeof(String)) { value = fieldValue.ToString(); value = value.Replace("'", "''"); criteria = fieldName + strOperator + "'" + value + "'"; } else if (sysType == typeof(DateTime)) { value = fieldValue.ToString(); criteria = fieldName + strOperator + "'" + value + "'"; } else if (sysType == typeof(Int16) || sysType == typeof(Int32) || sysType == typeof(Int64) || sysType == typeof(Decimal)) { value = fieldValue.ToString(); criteria = fieldName + strOperator + value; } else if (sysType == typeof(DBNull)) { value = "Null"; if (eO == Operators.Not) { criteria = fieldName + " is not " + value; } else { criteria = fieldName + " is " + value; } } } if (tableName.Trim().Length > 0) { criteria = tableName + "." + criteria; } } else { if (fieldName.Trim().Length > 0) { throw new Exception("Field name is blank."); } if (fieldValue == null) { throw new Exception("Field value is Null."); } } return(criteria); } catch (Exception ex) { throw (ex); } }
public static String FormatCriteria(String fieldName, Object fieldValue, Operators eO, Type sysType, ConnectionLibrary eCl) { return(FormatCriteria(fieldName, fieldValue, eO, "", sysType, eCl)); }
public static String FormatCriteria(String fieldName, Object fieldValue, Operators eO, String tablename, ConnectionLibrary eCl) { return(FormatCriteria(fieldName, fieldValue, eO, tablename, fieldValue.GetType(), eCl)); }
public static String FormatCriteria(String fieldName, Object fieldValue, Operators eO, String tableName, Type sysType, ConnectionLibrary eCl) { String criteria = String.Empty; String value; String strOperator = AryOperator[Convert.ToInt32(eO)]; try { if (fieldName.Trim().Length > 0 && fieldValue != null) { if (eCl == ConnectionLibrary.SQlClient) { if (sysType == typeof(String)) { value = fieldValue.ToString(); value = value.Replace("'", "''"); criteria = fieldName + strOperator + "'" + value + "'"; } else if (sysType == typeof(DateTime)) { value = fieldValue.ToString(); criteria = fieldName + strOperator + "'" + value + "'"; } else if (sysType == typeof(Int16) || sysType == typeof(Int32) || sysType == typeof(Int64) || sysType == typeof(Decimal)) { value = fieldValue.ToString(); criteria = fieldName + strOperator + value; } else if (sysType == typeof(DBNull)) { value = "Null"; if (eO == Operators.Not) { criteria = fieldName + " is not " + value; } else { criteria = fieldName + " is " + value; } } } if (tableName.Trim().Length > 0) { criteria = tableName + "." + criteria; } } else { if (fieldName.Trim().Length > 0) { throw new Exception("Field name is blank."); } if (fieldValue == null) { throw new Exception("Field value is Null."); } } return criteria; } catch (Exception ex) { throw (ex); } }
public static String FormatCriteria(String fieldName, Object fieldValue, Operators eO, Type sysType, ConnectionLibrary eCl) { return FormatCriteria(fieldName, fieldValue, eO, "", sysType, eCl); }
public static String FormatCriteria(String fieldName, Object fieldValue, Operators eO, String tablename, ConnectionLibrary eCl) { return FormatCriteria(fieldName, fieldValue, eO, tablename, fieldValue.GetType(), eCl); }