示例#1
0
        public static List <String> GetDatabases(ConversionConfiguration config)
        {
            try
            {
                String connectionString = config.ConnectionString;
                var    databases        = new List <String>();
                using (var conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    // Get the names of all DBs in the database server.
                    var query = new SqlCommand(@"SELECT DISTINCT [name] FROM sysdatabases", conn);
                    using (SqlDataReader reader = query.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            databases.Add((String)reader[0]);
                        }
                    }
                }
                return(databases);
            }
            catch (Exception ex)
            {
                SqlServerToSQLite.Log.Error("Error in \"GetDatabases\"", ex);
                return(null);
            }
        }
示例#2
0
 /// <summary>
 /// Get all configurations
 /// </summary>
 public GlobalConfiguration()
 {
     Server      = new ServerConfiguration();
     Application = new ApplicationConfiguration();
     Common      = new CommonConfiguration();
     Conversion  = new ConversionConfiguration();
 }
示例#3
0
        private void UpdateUI()
        {
            try
            {
                _isLoading = true;
                ConversionConfiguration config = this._manager.CurrentConfiguration;

                var filePathWithReplacedEnvironmentValues = Environment.ExpandEnvironmentVariables(config.SqLiteDatabaseFilePath);

                txtSqlAddress.Text = config.SqlServerAddress;
                txtSQLitePath.Text = filePathWithReplacedEnvironmentValues;
                txtPassword.Text   = config.EncryptionPassword;
                txtUserDB.Text     = config.User;
                txtPassDB.Text     = config.Password;

                if (!String.IsNullOrWhiteSpace(config.DatabaseName))
                {
                    int cboDatabaseIndex;
                    if (cboDatabases.Items.Contains(config.DatabaseName))
                    {
                        cboDatabaseIndex = cboDatabases.Items.IndexOf(config.DatabaseName);
                    }
                    else
                    {
                        cboDatabaseIndex = cboDatabases.Items.Add(config.DatabaseName);
                    }
                    cboDatabases.SelectedIndex = cboDatabaseIndex;
                }


                cbxEncrypt.Checked     = !(String.IsNullOrWhiteSpace(config.EncryptionPassword));
                cbxTriggers.Checked    = config.CreateTriggersEnforcingForeignKeys;
                cbxCreateViews.Checked = config.TryToCreateViews;
                cbxIntegrated.Checked  = config.IntegratedSecurity;

                if (config.IntegratedSecurity)
                {
                    lblPassword.Enabled = false;
                    lblUser.Enabled     = false;
                    txtPassDB.Enabled   = false;
                    txtUserDB.Enabled   = false;
                }
                else
                {
                    lblPassword.Enabled = true;
                    lblUser.Enabled     = true;
                    txtPassDB.Enabled   = true;
                    txtUserDB.Enabled   = true;
                }
                _isLoading = false;

                UpdateSensitivity();
            }
            catch (Exception ex)
            {
                SqlServerToSQLite.Log.Error("Error in \"UpdateUI\"", ex);
                // Do nothing.
            }
        }
示例#4
0
        public IndexTests()
        {
            this.MockModalService   = new Mock <ModalService>();
            this.MockDomainServices = new Mock <IServices>();

            var mapper = new ConversionConfiguration().MapperConfig.CreateMapper();

            this.Converter = new AutoMapperConversionService(mapper);
        }
示例#5
0
        public ServiceTestBase(ITestOutputHelper output)
        {
            var mapper = new ConversionConfiguration().MapperConfig.CreateMapper();

            this.Converter = new AutoMapperConversionService(mapper);

            var unitOfWork = CreateUnitOfWork(output);

            this.DomainServices = new DomainServices(unitOfWork, this.Converter);
        }
        public void MemberWithConverterType_IsColumnMember()
        {
            var config = new ConversionConfiguration();

            config.AddConvertor(new ValueConverter <Id <SingleProperty>, int>(model => model.Value, provider => (Id <SingleProperty>)provider));
            var searcher = new GraphSearcher(config);
            var graph    = searcher.SearchGraph(typeof(SingleProperty));

            graph.Nodes.Should().ContainSingle()
            .Which.ColumnMembers.Should().ContainSingle(x => x.Name == nameof(SingleProperty.Id) && ((PropertyInfo)x).PropertyType == typeof(Id <SingleProperty>));
        }
示例#7
0
        public void PrimitiveTypeAsRoot_WillBeEmptyGraph()
        {
            var primitiveType = typeof(int);
            var config        = new ConversionConfiguration
            {
                IsAllowedForColumn = x => x == primitiveType,
            };
            var searcher = new GraphSearcher(config);
            var graph    = searcher.SearchGraph(primitiveType);

            graph.Nodes.Should().BeEmpty();
        }
示例#8
0
        private RecordingMetadata ConvertZoomRecording(string inputFileName, string outputFolder)
        {
            // setup recording
            var config = new ConversionConfiguration()
            {
                SlideVideoPath  = inputFileName,
                OutputDirectory = outputFolder,
                ProjectName     = Path.GetFileName(inputFileName),
                ExportJson      = false
            };

            return(converter.ConvertPreviewZoomMedia(config));
        }
示例#9
0
        public void CyclicGraphs_DontCauseEndlessRecursion()
        {
            var primitiveType = typeof(int);
            var config        = new ConversionConfiguration
            {
                IsAllowedForColumn          = x => false,
                ShouldMediateTargetProperty = x => true,
            };
            var searcher = new GraphSearcher(config);
            var graph    = searcher.SearchGraph(typeof(CycleLink1));

            graph.Nodes.Select(_ => _.Type).Should().Contain(new[] { typeof(CycleLink1), typeof(CycleLink2) });
        }
示例#10
0
        public ServiceTestBase()
        {
            var mapper = new ConversionConfiguration().MapperConfig.CreateMapper();

            this.Converter = new AutoMapperConversionService(mapper);

            this.MockUnitOfWork           = new Mock <IUnitOfWork>();
            this.MockIngredientRepository = new Mock <IIngredientRepository>();

            this.MockUnitOfWork.SetupGet(m => m.IngredientRepository).Returns(() => this.MockIngredientRepository.Object);

            this.DomainServices = new DomainServices(this.MockUnitOfWork.Object, this.Converter);
        }
示例#11
0
        private RecordingMetadata ConvertStudioRecording(string inputFileName, string outputFolder)
        {
            // identify file paths
            var slideVideoPath = inputFileName.Replace("_meta.json", "_slides.mp4");
            var thVideoPath    = inputFileName.Replace("_meta.json", "_talkinghead.mp4");
            var ckFile         = inputFileName.Replace("_meta.json", ".ckparams");

            // setup of recording
            var targetDimension = Dimension.Dim720p;
            var recordingStyle  = new TKStudioStyle(targetDimension);

            if (File.Exists(ckFile))
            {
                dynamic ckInfo = JsonConvert.DeserializeObject(File.ReadAllText(ckFile));

                if (ckInfo["color"] != null)
                {
                    recordingStyle.ChromaKeyParams.Color = ckInfo["color"];
                }
                else
                {
                    recordingStyle.ChromaKeyParams.Color = chromaKeyParamGuesser.GuessChromaKeyParams(thVideoPath);
                }

                if (ckInfo["similarity"] != null)
                {
                    recordingStyle.ChromaKeyParams.Similarity = ckInfo["similarity"];
                }
                if (ckInfo["blend"] != null)
                {
                    recordingStyle.ChromaKeyParams.Blend = ckInfo["blend"];
                }
            }
            else
            {
                recordingStyle.ChromaKeyParams.Color = chromaKeyParamGuesser.GuessChromaKeyParams(thVideoPath);
            }

            var config = new ConversionConfiguration()
            {
                SlideVideoPath       = slideVideoPath,
                TalkingHeadVideoPath = thVideoPath,
                MetadataPath         = inputFileName,
                OutputDirectory      = outputFolder,
                ProjectName          = Path.GetFileName(inputFileName).Replace("_meta.json", ""),
                RecordingStyle       = recordingStyle,
                ExportJson           = false
            };

            return(converter.ConvertPreviewMedia(config));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GlobalConfiguration"/> class.
 /// Get all configurations.
 /// </summary>
 public GlobalConfiguration()
 {
     this.server      = new ServerConfiguration();
     this.application = new ApplicationConfiguration();
     this.signature   = new SignatureConfiguration();
     this.viewer      = new ViewerConfiguration();
     this.common      = new CommonConfiguration();
     this.annotation  = new AnnotationConfiguration();
     this.comparison  = new ComparisonConfiguration();
     this.conversion  = new ConversionConfiguration();
     this.editor      = new EditorConfiguration();
     this.metadata    = new MetadataConfiguration();
     this.search      = new SearchConfiguration();
 }
示例#13
0
        public void TryingToSearchMoreThanMaxLevelDeep_ThrowsSanityException()
        {
            var primitiveType = typeof(int);
            var config        = new ConversionConfiguration
            {
                IsAllowedForColumn          = x => false,
                ShouldMediateTargetProperty = x => true,
                MaxRecursion = 0,
            };
            var searcher = new GraphSearcher(config);

            searcher.Invoking(x => x.SearchGraph(typeof(Outer)))
            .Should().Throw <SanityException>().WithMessage("*recursion limit*");
        }
示例#14
0
        public void SelectWithMultiplePropertyChain_IsProperlyMaterialized()
        {
            using (var connection = new SQLiteConnection("data source=:memory:"))
            {
                connection.Open();
                using (var ctx = new OrderContext(connection))
                {
                    var order = new Order
                    {
                        Items = new List <OrderItem>
                        {
                            new OrderItem
                            {
                                Product = new Product {
                                    Name = "Diapers", Cost = 10.0m
                                },
                                Quantity = 5,
                            },
                            new OrderItem
                            {
                                Product = new Product {
                                    Name = "Baby formula", Cost = 50m
                                },
                                Quantity = 3,
                            },
                        },
                    };
                    ctx.Orders.Add(order);
                    ctx.SaveChanges();

                    var config = new ConversionConfiguration()
                    {
                        IsAllowedForColumn = x => x.IsValueType || x == typeof(string),
                    };
                    var searcher       = new GraphSearcher(config);
                    var graph          = searcher.SearchGraph(typeof(B));
                    var mediatorMapper = new MediatorTypeBuilder().CreateMediatorTypes(graph);
                    var result         = ctx.OrderItems.ProjectToList(
                        x => new B
                    {
                        ProductCost = x.Product.Cost,
                    },
                        mediatorMapper);
                    result.Select(x => x.ProductCost).Should().BeEquivalentTo(10m, 50m);
                }
            }
        }
示例#15
0
        public void PropertiesMaterializedFromDbColumnAreAlwaysAllowed()
        {
            var originType    = typeof(Outer);
            var primitiveType = new Outer().Primitive.GetType();
            var config        = new ConversionConfiguration
            {
                IsAllowedForColumn          = x => x == primitiveType,
                ShouldMediateTargetProperty = x => false,
            };
            var searcher = new GraphSearcher(config);
            var graph    = searcher.SearchGraph(originType);

            graph.Nodes.Should().ContainSingle()
            .Which.Type.Should().Be(originType);
            graph.Nodes.Single().ColumnMembers
            .Should().Equal(typeof(Outer).GetProperty(nameof(Outer.Primitive)));
        }
示例#16
0
        private void AssertTargetToMediator <TParameter, TResult>(
            Expression <Func <TParameter, TResult> > projection,
            string resultTargetToMediator)
        {
            var config = new ConversionConfiguration()
            {
                IsAllowedForColumn = x => x.IsValueType || x == typeof(string),
            };
            var searcher = new GraphSearcher(config);
            var graph    = searcher.SearchGraph(typeof(TResult));

            var mediatorMapper = new MediatorTypeBuilder().CreateMediatorTypes(graph);

            var targetToMediatorVisitor = new TargetToMediatorVisitor(mediatorMapper);
            var result = targetToMediatorVisitor.Visit(projection);

            result.ToString("C#").Should().Be(resultTargetToMediator.Trim());
        }
示例#17
0
        public void GraphHasMultipleLevels_AllAreFound()
        {
            var originType = typeof(Outer);
            var config     = new ConversionConfiguration
            {
                IsAllowedForColumn          = x => x.IsPrimitive,
                ShouldMediateTargetProperty = x => true,
            };
            var searcher = new GraphSearcher(config);
            var graph    = searcher.SearchGraph(originType);

            graph.Nodes.Select(x => x.Type).Should().BeEquivalentTo(typeof(Outer), typeof(Inner), typeof(Innermost));
            var outerNode     = graph.Nodes.Single(x => x.Type == typeof(Outer));
            var innerNode     = graph.Nodes.Single(x => x.Type == typeof(Inner));
            var innermostNode = graph.Nodes.Single(x => x.Type == typeof(Innermost));

            graph.Edges.Should().BeEquivalentTo(
                new Edge(outerNode, innerNode, typeof(Outer).GetProperty(nameof(Outer.Inner))),
                new Edge(innerNode, innermostNode, typeof(Inner).GetProperty(nameof(Inner.Innermost))));
        }
示例#18
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (!EnsureSaveLocationExists())
            {
                MessageBox.Show("Specified save location is in a directory that does not exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ConversionConfiguration config = _manager.CurrentConfiguration;
            string sqlConnString           = config.ConnectionString;

            Cursor = Cursors.WaitCursor;
            SqlConversionProgressReportingHandler progressReportingHandler = OnSqlConversionProgressReportingHandler;
            SqlTableSelectionHandler    selectionHandlerDefinition         = OnSqlTableDefinitionSelectionHandler;
            SqlTableSelectionHandler    selectionHandlerRecords            = OnSqlTableRecordSelectionHandler;
            FailedViewDefinitionHandler viewFailureHandler = OnFailedViewDefinitionHandler;

            var filePathWithReplacedEnvironmentValues = Environment.ExpandEnvironmentVariables(config.SqLiteDatabaseFilePath);

            SqlServerToSQLite.ConvertSqlServerToSQLiteDatabase(sqlConnString, filePathWithReplacedEnvironmentValues, config.EncryptionPassword, progressReportingHandler, selectionHandlerDefinition, selectionHandlerRecords, viewFailureHandler, config.CreateTriggersEnforcingForeignKeys, config.TryToCreateViews);
        }
示例#19
0
        private void ToolStripMenuItemSave(object sender, EventArgs e)
        {
            var dlg = new SaveFileDialog();

            dlg.AddExtension     = true;
            dlg.DefaultExt       = "xml";
            dlg.FileName         = "SqlConverter.Configuration.xml";
            dlg.Filter           = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
            dlg.RestoreDirectory = true; //this opens the last used directory location instead of defaulting to desktop

            var result = dlg.ShowDialog();

            if (result == DialogResult.OK)
            {
                ConversionConfiguration config = _manager.CurrentConfiguration;
                using (var sw = new StreamWriter(dlg.OpenFile()))
                {
                    sw.Write(config.SerializedXml);
                }
            }
        }
        private RecordingMetadata ConvertSimpleRecording(string inputFileName, string outputFolder, Dimension targetDimension)
        {
            // identify file paths
            var slideVideoPath = inputFileName.Replace("_meta.json", "_slides.mp4");
            var thVideoPath    = inputFileName.Replace("_meta.json", "_talkinghead.mp4");

            // setup of recording
            var recordingStyle = new TKSimpleStyle(targetDimension);

            var config = new ConversionConfiguration()
            {
                SlideVideoPath       = slideVideoPath,
                TalkingHeadVideoPath = thVideoPath,
                MetadataPath         = inputFileName,
                OutputDirectory      = outputFolder,
                ProjectName          = Path.GetFileName(inputFileName).Replace("_meta.json", ""),
                RecordingStyle       = recordingStyle,
                ExportJson           = false
            };

            return(converter.ConvertMedia(config));
        }
示例#21
0
 public ConversionConfigurationTests()
 {
     _instanceUnderTest = new ConversionConfiguration <object, string>(null, _converterSink.Object);
 }