Exemple #1
0
        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));
            }
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
 /// <summary>
 /// default constructor (with dependency input)
 /// </summary>
 /// <param name="sourceDataAccess">the data access object to use when getting data</param>
 public SourceData(ISourceDataAccess sourceDataAccess)
 {
     _sourceDataAccess = sourceDataAccess;
 }
Exemple #6
0
 public BcMooreService(ISourceDataAccess dataAccess)
 {
     _dataAccess = dataAccess;
 }
Exemple #7
0
        /// <summary>
        /// commit pending changes for a changeset that have been merged for the specified target using the provided data access instance
        /// </summary>
        /// <param name="dataAccess">the implementation of the data access to use when getting the data</param>
        /// <param name="environment"></param>
        /// <param name="comment"></param>
        /// <param name="changeset"></param>
        public static Changeset CommitChangeset(ISourceDataAccess dataAccess, Changeset changeset, MergeEnvironment environment, string comment)
        {
            var da = new Data.Source.SourceData(dataAccess);

            return(da.CommitChangeset(changeset, environment, comment));
        }
Exemple #8
0
        /// <summary>
        /// commit pending changes using the provided data access instance
        /// </summary>
        /// <param name="dataAccess">the implementation of the data access to use when getting the data</param>
        /// <param name="comment"></param>
        /// <param name="associatedWorkItems"></param>
        public static Changeset CommitPending(ISourceDataAccess dataAccess, string comment, IEnumerable <WorkItem> associatedWorkItems)
        {
            var da = new Data.Source.SourceData(dataAccess);

            return(da.CommitPending(comment, associatedWorkItems));
        }
Exemple #9
0
        /// <summary>
        /// merge changeset using provided data access instance
        /// </summary>
        /// <param name="dataAccess">the implementation of the data access to use when getting the data</param>
        /// <param name="changeset"></param>
        /// <param name="environment"></param>
        public static MergeStatus MergeChangeset(ISourceDataAccess dataAccess, Changeset changeset, MergeEnvironment environment)
        {
            var da = new Data.Source.SourceData(dataAccess);

            return(da.MergeChangeset(changeset, environment));
        }
Exemple #10
0
        /// <summary>
        /// get merge candidates for a project and environment
        /// </summary>
        /// <param name="dataAccess"></param>
        /// <param name="project"></param>
        /// <param name="environment"></param>
        /// <returns></returns>
        public static IEnumerable <Changeset> GetMergeCandidates(ISourceDataAccess dataAccess, Project project, MergeEnvironment environment)
        {
            var da = new Data.Source.SourceData(dataAccess);

            return(da.GetMergeCandidates(project, environment));
        }
Exemple #11
0
        /// <summary>
        /// get changesets using provided data access instance
        /// </summary>
        /// <param name="dataAccess">the implementation of the data access to use when getting the data</param>
        /// <param name="project"></param>
        /// <param name="state"></param>
        /// <param name="environment"></param>
        public static IEnumerable <Changeset> GetChangesetsByWorkItemState(ISourceDataAccess dataAccess, Project project, string state, MergeEnvironment environment)
        {
            var da = new Data.Source.SourceData(dataAccess);

            return(da.GetChangesetsByWorkItemState(project, state, environment));
        }
Exemple #12
0
        /// <summary>
        /// get changesets using provided data access instance
        /// </summary>
        /// <param name="dataAccess">the implementation of the data access to use when getting the data</param>
        /// <param name="workItem"></param>
        /// <param name="environment"></param>
        public static IEnumerable <Changeset> GetChangesets(ISourceDataAccess dataAccess, IWorkItem workItem, MergeEnvironment environment)
        {
            var da = new Data.Source.SourceData(dataAccess);

            return(da.GetChangesets(workItem, environment));
        }
Exemple #13
0
        /// <summary>
        /// get changesets using provided data access instance
        /// </summary>
        /// <param name="dataAccess">the implementation of the data access to use when getting the data</param>
        /// <param name="workItem"></param>
        public static IEnumerable <Changeset> GetChangesets(ISourceDataAccess dataAccess, IWorkItem workItem)
        {
            var da = new Data.Source.SourceData(dataAccess);

            return(da.GetChangesets(workItem));
        }
Exemple #14
0
 public Database(DataAccess da)
 {
     _sourceDA = SourceDataAccessFactory.CreateDataAccess(SourceDatabaseType.TSQL);
     _da       = new DataAccess();
 }
Exemple #15
0
 /// <summary>
 /// default constructor (passes in dataaccess layer dependency)
 /// </summary>
 /// <param name="sourceDataAccess"></param>
 public SourceRepository(ISourceDataAccess sourceDataAccess)
 {
     SourceDataAccess = sourceDataAccess;
 }