public JsonResult AddDataSourceTable(int DataSourceId, string TableName) { Object returnData; try { ISourceDataAccess dataAccess = SourceDataAccessFactory.CreateDataAccess(Common.Enums.SourceDatabaseType.TSQL); TableModel table = dataAccess.ListAllTables().Single(x => x.TableName == TableName); DataSourceTable dsTable = new DataSourceTable(); dsTable.DataSourceId = DataSourceId; dsTable.CreatedBy = GetCurrentUser().Email; dsTable.CreatedDate = DateTime.Now; dsTable.DataSourceTableIdGuid = Guid.NewGuid(); dsTable.TableAlias = table.TableName.Replace("SRC_", ""); dsTable.TableName = table.TableName; dsTable.Columns = new JavaScriptSerializer().Serialize(table.Columns); SqlConfidenceContext context = new SqlConfidenceContext(); context.DataSourceTables.Add(dsTable); context.SaveChanges(); returnData = new { Success = true }; return(Json(returnData)); } catch (Exception ex) { returnData = new { Success = false, ErrorMessage = "Error adding table, please check the logs" }; Trace.WriteLine(String.Format("Error adding table {0} to {1} - {2}", TableName, DataSourceId, ex.Message)); return(Json(returnData)); } }
public ActionResult DataSource(DataSource DataSource) { SqlConfidenceContext context = new SqlConfidenceContext(); if (!String.IsNullOrEmpty(DataSource.Name)) { try { var original = context.DataSources.Find(DataSource.DataSourceId); context.Entry(original).CurrentValues.SetValues(DataSource); original.UpdatedBy = GetCurrentUser().Email; original.UpdatedDate = DateTime.Now; context.SaveChanges(); ViewBag.SuccessMessage = "Saved Successfully"; } catch (Exception ex) { Trace.WriteLine("Error saving exercise - " + ex.Message); ViewBag.ErrorMessage = "Error saving exercise, please check the logs"; } } DataSource = context.DataSources.Single(x => x.DataSourceId == DataSource.DataSourceId); ISourceDataAccess dataAccess = SourceDataAccessFactory.CreateDataAccess(Common.Enums.SourceDatabaseType.TSQL); ViewBag.Tables = dataAccess.ListAllTables(); return(View(DataSource)); }
public DataSourceTableService( IDataSourceTableRepository DataSourceTableRepository) { _dataSourceTableRepository = DataSourceTableRepository; var sourceDA = SourceDataAccessFactory.CreateDataAccess(Enums.SourceDatabaseType.TSQL); _tableModels = sourceDA.ListAllTables(); }
public void GetDifferences_should_not_be_slow_on_large_datasets() { ISourceDataAccess da = SourceDataAccessFactory.CreateDataAccess(SourceDatabaseType.TSQL); DataTable dt1 = da.GetDataTable("select * FROM SRC_EMARKETING_EMAIL ORDER BY EmailId ASC"); DataTable dt2 = da.GetDataTable("select * FROM SRC_EMARKETING_EMAIL ORDER BY EmailId DESC"); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var results = new DifferenceEngine().GetDifferences(dt1, dt2); stopwatch.Stop(); Assert.IsTrue(stopwatch.ElapsedMilliseconds < 200); }
public void GetDifferences_should_not_be_slow() { ISourceDataAccess da = SourceDataAccessFactory.CreateDataAccess(SourceDatabaseType.TSQL); DataTable dt1 = da.GetDataTable("select exq.exq_description, count(exqa.exqa_id) 'times_answered' from src_exercises_questions exq left join src_exercises_questions_answered exqa on exq.exq_id = exqa.exq_id group by exq.exq_id, exq.exq_description"); DataTable dt2 = da.GetDataTable("select exq.exq_description, count(*) 'times_answered' from src_exercises_questions exq left join src_exercises_questions_answered exqa on exq.exq_id = exqa.exq_id group by exq.exq_id, exq.exq_description"); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var results = new DifferenceEngine().GetDifferences(dt1, dt2); stopwatch.Stop(); Assert.IsTrue(stopwatch.ElapsedMilliseconds < 200); }