Example #1
0
        /// <summary>
        /// Checks that the file exists
        /// </summary>
        /// <param name="notifier"></param>
        public void Check(ICheckNotifier notifier)
        {
            try
            {
                FileInfo fileInfo = new FileInfo(URL);

                if (fileInfo.Exists)
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Found intact attachment file " + fileInfo + " with length " +
                            UsefulStuff.GetHumanReadableByteSize(fileInfo.Length), CheckResult.Success));
                }
                else
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "File " + fileInfo.FullName + " does not exist (for GovernanceDocument '" + this + "' (ID=" +
                            ID + ")", CheckResult.Fail));
                }
            }
            catch (Exception ex)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "Failed to check for existance of the file described by GovernanceDocument '" + this + "' (ID=" +
                        ID + ")", CheckResult.Fail, ex));
            }
        }
Example #2
0
        public ExitCodeType Execute(string commandText, DiscoveredDatabase db)
        {
            var syntax = db.Server.GetQuerySyntaxHelper();

            commandText = _regexEntity.Replace(commandText, m => GetEntityForMatch(m, syntax));

            try
            {
                Dictionary <int, Stopwatch> performance = new Dictionary <int, Stopwatch>();


                using (var con = db.Server.GetConnection())
                {
                    con.Open();
                    UsefulStuff.ExecuteBatchNonQuery(commandText, con, null, out performance, 600000);
                }

                foreach (KeyValuePair <int, Stopwatch> section in performance)
                {
                    _job.OnNotify(this,
                                  new NotifyEventArgs(ProgressEventType.Information,
                                                      "Batch ending on line  \"" + section.Key + "\" finished after " + section.Value.Elapsed));
                }
            }
            catch (Exception e)
            {
                throw new Exception("Failed to execute the query: " + e);
            }

            return(ExitCodeType.Success);
        }
Example #3
0
        public void CheckForVersionMismatches(ICheckNotifier notifier)
        {
            SetupMEFIfRequired();

            DirectoryInfo root = new DirectoryInfo(".");

            var binDirectoryFiles = root.EnumerateFiles().ToArray();

            foreach (FileInfo dllInMEFFolder in DownloadDirectory.GetFiles())
            {
                FileInfo dllInBinFolder = binDirectoryFiles.FirstOrDefault(f => f.Name.Equals(dllInMEFFolder.Name));

                if (dllInBinFolder != null)
                {
                    string md5Bin = UsefulStuff.HashFile(dllInBinFolder.FullName);
                    string md5Mef = UsefulStuff.HashFile(dllInMEFFolder.FullName);

                    if (!md5Bin.Equals(md5Mef))
                    {
                        notifier.OnCheckPerformed(new CheckEventArgs("Different versions of the dll exist in MEF and BIN directory:" + Environment.NewLine +
                                                                     dllInBinFolder.FullName + " (MD5=" + md5Bin + ")" + Environment.NewLine +
                                                                     "Version:" + FileVersionInfo.GetVersionInfo(dllInBinFolder.FullName).FileVersion + Environment.NewLine +
                                                                     "and" + Environment.NewLine +
                                                                     dllInMEFFolder.FullName + " (MD5=" + md5Mef + ")" + Environment.NewLine +
                                                                     "Version:" + FileVersionInfo.GetVersionInfo(dllInMEFFolder.FullName).FileVersion + Environment.NewLine
                                                                     , CheckResult.Warning, null));
                    }
                }
            }
        }
Example #4
0
        public void Create(DiscoveredDatabase databaseICanCreateRandomTablesIn, ICatalogueRepository catalogueRepository)
        {
            CreateFunctionSQL = @"
if exists (select 1 from sys.objects where name = 'MyAwesomeFunction')
    drop function MyAwesomeFunction
GO

CREATE FUNCTION MyAwesomeFunction
(	
	-- Add the parameters for the function here
	@startNumber int ,
	@stopNumber int,
	@name varchar(50)
)
RETURNS
@ReturnTable TABLE 
(
	-- Add the column definitions for the TABLE variable here
	Number int, 
	Name varchar(50)
)
AS
BEGIN
	-- Fill the table variable with the rows for your result set
	DECLARE @i int;
	set @i = @startNumber

	while(@i < @stopNumber)
		begin
		INSERT INTO @ReturnTable(Name,Number) VALUES (@name,@i);
		set @i = @i + 1;
		end

	RETURN 
END
";
            using (var con = databaseICanCreateRandomTablesIn.Server.GetConnection())
            {
                con.Open();
                UsefulStuff.ExecuteBatchNonQuery(CreateFunctionSQL, con);
            }
            var tbl = databaseICanCreateRandomTablesIn.ExpectTableValuedFunction("MyAwesomeFunction");
            TableValuedFunctionImporter importer = new TableValuedFunctionImporter(catalogueRepository, tbl);

            importer.DoImport(out TableInfoCreated, out ColumnInfosCreated);

            importer.ParametersCreated[0].Value = "5";
            importer.ParametersCreated[0].SaveToDatabase();

            importer.ParametersCreated[1].Value = "10";
            importer.ParametersCreated[1].SaveToDatabase();

            importer.ParametersCreated[2].Value = "'fish'";
            importer.ParametersCreated[2].SaveToDatabase();


            ForwardEngineerCatalogue forwardEngineerCatalogue = new ForwardEngineerCatalogue(TableInfoCreated, ColumnInfosCreated, true);

            forwardEngineerCatalogue.ExecuteForwardEngineering(out Cata, out CataItems, out ExtractionInformations);
        }
Example #5
0
        private void SetupLowPrivilegeUserRightsFor(DiscoveredDatabase db, TestLowPrivilegePermissions permissions, ITableInfo ti)
        {
            var dbType = db.Server.DatabaseType;

            //get access to the database using the current credentials
            var username = TestDatabaseSettings.GetLowPrivilegeUsername(dbType);
            var password = TestDatabaseSettings.GetLowPrivilegePassword(dbType);

            if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
            {
                Assert.Inconclusive();
            }

            //give the user access to the table
            var sql = GrantAccessSql(username, dbType, permissions);

            using (var con = db.Server.GetConnection())
                UsefulStuff.ExecuteBatchNonQuery(sql, con);

            if (ti != null)
            {
                //remove any existing credentials
                foreach (DataAccessCredentials cred in CatalogueRepository.GetAllObjects <DataAccessCredentials>())
                {
                    CatalogueRepository.TableInfoCredentialsManager.BreakAllLinksBetween(cred, ti);
                }

                //set the new ones
                DataAccessCredentialsFactory credentialsFactory = new DataAccessCredentialsFactory(CatalogueRepository);
                credentialsFactory.Create(ti, username, password, DataAccessContext.Any);
            }
        }
Example #6
0
        private void BuildSwitchInstanceMenuItems()
        {
            var args = RDMPBootStrapper <RDMPMainForm> .ApplicationArguments;

            // somehow app was launched without populating the load args
            if (args == null)
            {
                return;
            }

            var origYamlFile = args.ConnectionStringsFileLoaded;

            //default settings were used if no yaml file was specified or the file specified did not exist
            var defaultsUsed = origYamlFile == null;

            // if defaults were not used then it is valid to switch to them
            switchToDefaultSettings.Enabled = !defaultsUsed;

            switchToDefaultSettings.Checked      = defaultsUsed;
            launchNewWithDefaultSettings.Checked = defaultsUsed;

            // load the yaml files in the RDMP binary directory
            var exeDir = UsefulStuff.GetExecutableDirectory();

            AddMenuItemsForSwitchingToInstancesInYamlFilesOf(origYamlFile, exeDir);

            // also add yaml files from wherever they got their original yaml file
            if (origYamlFile?.FileLoaded != null && !exeDir.FullName.Equals(origYamlFile.FileLoaded.Directory.FullName))
            {
                AddMenuItemsForSwitchingToInstancesInYamlFilesOf(origYamlFile, origYamlFile.FileLoaded.Directory);
            }
        }
Example #7
0
        public static void SetValue(PropertyInfo prop, object value, IMapsDirectlyToDatabaseTable onObject)
        {
            //sometimes json decided to swap types on you e.g. int64 for int32
            var propertyType = prop.PropertyType;

            //if it is a nullable int etc
            if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                propertyType = propertyType.GetGenericArguments()[0]; //lets pretend it's just int / whatever
            }
            if (value != null && value != DBNull.Value && !propertyType.IsInstanceOfType(value))
            {
                if (propertyType == typeof(CatalogueFolder))
                {
                    //will be passed as a string
                    value = value is string?new CatalogueFolder((Catalogue)onObject, (string)value) : (CatalogueFolder)value;
                }
                else if (propertyType == typeof(Uri))
                {
                    value = value is string?new Uri((string)value) : (Uri)value;
                }
                else
                if (typeof(Enum).IsAssignableFrom(propertyType))
                {
                    value = Enum.ToObject(propertyType, value);//if the property is an enum
                }
                else
                {
                    value = UsefulStuff.ChangeType(value, propertyType); //the property is not an enum
                }
            }
            prop.SetValue(onObject, value); //if it's a shared property (most properties) use the new shared value being imported
        }
Example #8
0
        public void PascalCaseStringToHumanReadable()
        {
            Assert.AreEqual("teststringhere", UsefulStuff.PascalCaseStringToHumanReadable("teststringhere"));
            Assert.AreEqual("test Stringhere", UsefulStuff.PascalCaseStringToHumanReadable("testStringhere"));
            Assert.AreEqual("test String Here", UsefulStuff.PascalCaseStringToHumanReadable("testStringHere"));
            Assert.AreEqual("Test String Here", UsefulStuff.PascalCaseStringToHumanReadable("TestStringHere"));
            Assert.AreEqual("TEST String Here", UsefulStuff.PascalCaseStringToHumanReadable("TESTStringHere"));
            Assert.AreEqual("Test STRING Here", UsefulStuff.PascalCaseStringToHumanReadable("TestSTRINGHere"));
            Assert.AreEqual("Test String HERE", UsefulStuff.PascalCaseStringToHumanReadable("TestStringHERE"));

            //Some practical tests for completeness sake
            Assert.AreEqual("A", UsefulStuff.PascalCaseStringToHumanReadable("A"));
            Assert.AreEqual("AS", UsefulStuff.PascalCaseStringToHumanReadable("AS"));
            Assert.AreEqual("A String", UsefulStuff.PascalCaseStringToHumanReadable("AString"));
            Assert.AreEqual("String A Test", UsefulStuff.PascalCaseStringToHumanReadable("StringATest"));
            Assert.AreEqual("String AS Test", UsefulStuff.PascalCaseStringToHumanReadable("StringASTest"));
            Assert.AreEqual("CT Head", UsefulStuff.PascalCaseStringToHumanReadable("CTHead"));
            Assert.AreEqual("WHERE Clause", UsefulStuff.PascalCaseStringToHumanReadable("WHEREClause"));
            Assert.AreEqual("Sql WHERE", UsefulStuff.PascalCaseStringToHumanReadable("SqlWHERE"));

            Assert.AreEqual("Test String", UsefulStuff.PascalCaseStringToHumanReadable("Test_String"));
            Assert.AreEqual("Test string", UsefulStuff.PascalCaseStringToHumanReadable("Test_string"));
            Assert.AreEqual("test String", UsefulStuff.PascalCaseStringToHumanReadable("_testString"));
            Assert.AreEqual("test String", UsefulStuff.PascalCaseStringToHumanReadable("_testString_"));
        }
Example #9
0
        /// <summary>
        /// Finds the first nonterminal, and replaces it with one of the values found in its production.
        /// </summary>
        /// <param name="String">The string that will be analyzed.</param>
        /// <param name="productionList">The list of productions.</param>
        /// <param name="characterLimit">The maximum number of characters the final string should have. Default is 60.</param>
        /// <returns>The string after a succesful replace, or the same string if there are no more nonterminals or
        /// if it's above the limit.</returns>
        string Replace(string String, List <List <string> > productionList, int characterLimit = 60)
        {
            foreach (char character in String)
            {
                foreach (List <string> production in productionList)
                {
                    // If the character is found in a production
                    if (character == production[0][0] && String.Length < characterLimit)
                    {
                        // Get a random value from the production
                        int indexProductionValue    = randomNumberGenerator.Next(1, production.Count);
                        int indexCharacterToReplace = UsefulStuff.GetCharacterIndex(String, character);

                        // Replace character
                        String = String.Remove(indexCharacterToReplace, 1);
                        String = String.Insert(indexCharacterToReplace, production[indexProductionValue]);

                        // Return after replace
                        return(String);
                    }
                }
            }

            // In this phase, the string should be over the limit or it wouldn't contain any nonterminals
            return(String);
        }
Example #10
0
        private void ListAllTypesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var file = new FileInfo(Path.GetTempFileName());

            File.WriteAllText(file.FullName, string.Join(Environment.NewLine, Activator.RepositoryLocator.CatalogueRepository.MEF.GetAllTypes().Select(t => t.FullName)));
            UsefulStuff.GetInstance().ShowFileInWindowsExplorer(file);
        }
 public override void Activate(AllPluginsNode target)
 {
     if (ItemActivator.RepositoryLocator.CatalogueRepository.MEF.DownloadDirectory.Exists)
     {
         UsefulStuff.GetInstance().ShowFolderInWindowsExplorer(ItemActivator.RepositoryLocator.CatalogueRepository.MEF.DownloadDirectory);
     }
 }
Example #12
0
        [TestCase("", "varchar(1)", true)]//This data exists regardless of if it is blank so it still gets the 1
        public void DiluteToBitFlag(string input, string inputDataType, bool expectedDilute)
        {
            var tbl = Mock.Of <ITableInfo>(m => m.GetRuntimeName(LoadStage.AdjustStaging, null) == "DiluteToBitFlagTests");
            var col = Mock.Of <IPreLoadDiscardedColumn>(c =>
                                                        c.TableInfo == tbl &&
                                                        c.GetRuntimeName() == "TestField");

            var o = new CrushToBitFlag();

            o.ColumnToDilute = col;
            var sql = o.GetMutilationSql(null);

            var server = GetCleanedServer(FAnsi.DatabaseType.MicrosoftSQLServer).Server;

            using (var con = server.BeginNewTransactedConnection())
            {
                try
                {
                    string insert = input != null ? "'" + input + "'" : "NULL";

                    server.GetCommand(@"CREATE TABLE DiluteToBitFlagTests(TestField " + inputDataType + @")
INSERT INTO DiluteToBitFlagTests VALUES (" + insert + ")", con).ExecuteNonQuery();

                    UsefulStuff.ExecuteBatchNonQuery(sql, con.Connection, con.Transaction);

                    var result = server.GetCommand("SELECT * from DiluteToBitFlagTests", con).ExecuteScalar();

                    Assert.AreEqual(expectedDilute, Convert.ToBoolean(result));
                }
                finally
                {
                    con.ManagedTransaction.AbandonAndCloseConnection();
                }
            }
        }
Example #13
0
    void ShadowPlayerUpdate()
    {
        // maybe change logic here?
        destination = player.position + targetDirectionFromPlayer * distanceToMaintain;

        Vector3 movement = destination - this.transform.position;

        movement = movement.normalized * moveSpeed * shadowSpeedCoefficient * Time.fixedDeltaTime;

        // if we're close enough, don't overshoot
        if (UsefulStuff.CloseEnough(this.transform.position, destination, movement.sqrMagnitude))
        {
            movement = destination - this.transform.position;
        }
        else if (UsefulStuff.FarEnough(this.transform.position, destination, tooFarAway * tooFarAway))
        {
            BeginCatchUpToPlayer();
        }

        base.MoveWithSliding(
            new Vector3(
                movement.x,
                movement.y,
                0));
    }
Example #14
0
        public void SprayToDisk()
        {
            _fileLocations.Add(TestFile, UsefulStuff.SprayFile(typeof(ExcelTests).Assembly, typeof(ExcelTests).Namespace + ".TestFile." + TestFile, TestFile, TestContext.CurrentContext.TestDirectory));
            _fileLocations.Add(FreakyTestFile, UsefulStuff.SprayFile(typeof(ExcelTests).Assembly, typeof(ExcelTests).Namespace + ".TestFile." + FreakyTestFile, FreakyTestFile, TestContext.CurrentContext.TestDirectory));

            _fileLocations.Add(OddFormatsFile, UsefulStuff.SprayFile(typeof(ExcelTests).Assembly, typeof(ExcelTests).Namespace + ".TestFile." + OddFormatsFile, OddFormatsFile, TestContext.CurrentContext.TestDirectory));
        }
Example #15
0
        private void btnCreateYamlFile_Click(object sender, EventArgs e)
        {
            try
            {
                var toSerialize = new ConnectionStringsYamlFile()
                {
                    CatalogueConnectionString  = tbCatalogueConnectionString.Text,
                    DataExportConnectionString = tbDatabasePrefix.Text,
                };

                var serializer = new Serializer();
                var yaml       = serializer.Serialize(toSerialize);

                var sfd = new SaveFileDialog();
                sfd.Filter           = "Yaml|*.yaml";
                sfd.Title            = "Save yaml";
                sfd.InitialDirectory = UsefulStuff.GetExecutableDirectory().FullName;

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    File.WriteAllText(sfd.FileName, yaml);
                }
            }
            catch (Exception ex)
            {
                ExceptionViewer.Show(ex);
            }
        }
Example #16
0
        protected override bool SelectValueTypeImpl(DialogArgs args, Type paramType, object initialValue, out object chosen)
        {
            WritePromptFor(args);

            chosen = UsefulStuff.ChangeType(ReadLineWithAuto(), paramType);

            return(true);
        }
Example #17
0
        protected override string IsValid(object currentValue, Type typeToTest)
        {
            if (currentValue is string s)
            {
                return(UsefulStuff.IsBadName(s) ? "Name contains illegal characters":null);
            }

            return(null);
        }
Example #18
0
        public string DescribeProblem(object o)
        {
            if (o is INamed n && !_ignoreBadNamesFor.Contains(o.GetType()) && UsefulStuff.IsBadName(n.Name))
            {
                return("Name contains illegal characters");
            }

            return(DescribeProblemImpl(o));
        }
Example #19
0
        private void CreateCohortDatabase()
        {
            _cohortDatabase = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExpectDatabase(CohortDatabaseName);

            if (_cohortDatabase.Exists())
            {
                DeleteTables(_cohortDatabase);
            }
            else
            {
                _cohortDatabase.Create();
            }

            string sql = string.Format(@"

CREATE TABLE [dbo].[Cohort](
       [PrivateID] [varchar](10) NOT NULL,
       [ReleaseID] [varchar](10) NULL,
       [cohortDefinition_id] [int] NOT NULL,
CONSTRAINT [PK_Cohort] PRIMARY KEY CLUSTERED 
(
       [PrivateID] ASC,
       [cohortDefinition_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[CohortDefinition](
       [id] [int] IDENTITY(1,1) NOT NULL,
       [projectNumber] [int] NOT NULL,
       [version] [int] NOT NULL,
       [description] [varchar](4000) NOT NULL,
       [dtCreated] [date] NOT NULL,
CONSTRAINT [PK_CohortDefinition] PRIMARY KEY NONCLUSTERED 
(
       [id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[CohortDefinition] ADD  CONSTRAINT [DF_CohortDefinition_dtCreated]  DEFAULT (getdate()) FOR [dtCreated]
GO
ALTER TABLE [dbo].[Cohort]  WITH CHECK ADD  CONSTRAINT [FK_Cohort_CohortDefinition] FOREIGN KEY([cohortDefinition_id])
REFERENCES [dbo].[CohortDefinition] ([id])
GO
ALTER TABLE [dbo].[Cohort] CHECK CONSTRAINT [FK_Cohort_CohortDefinition]
GO
");

            using (var con = _cohortDatabase.Server.GetConnection())
            {
                con.Open();
                UsefulStuff.ExecuteBatchNonQuery(sql, con, timeout: 15);
                con.Close();
            }
        }
Example #20
0
        private void lvDatasets_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            var item = (OLVListItem)tlvDatasets.HitTest(e.Location).Item;


            if (item == null)
            {
                return;
            }

            var doc = item.RowObject as SupportingDocument;

            if (doc != null)
            {
                try
                {
                    UsefulStuff.GetInstance().ShowFileInWindowsExplorer(doc.GetFileName());
                }
                catch (Exception ex)
                {
                    ExceptionViewer.Show(ex);
                }
            }

            var sql = item.RowObject as SupportingSQLTable;

            if (sql != null)
            {
                try
                {
                    if (sql.ExternalDatabaseServer_ID == null)
                    {
                        throw new NotSupportedException("There is no known server for SupportingSql " + sql);
                    }

                    var server            = sql.ExternalDatabaseServer;
                    DataTableViewerUI dtv = new DataTableViewerUI(server, sql.SQL, sql.Name);
                    dtv.Show();
                }
                catch (Exception ex)
                {
                    ExceptionViewer.Show(ex);
                }
            }


            //User double clicks a lookup table
            var lookup = item.RowObject as BundledLookupTable;

            if (lookup != null)
            {
                ViewSQLAndResultsWithDataGridUI f = new ViewSQLAndResultsWithDataGridUI();
                f.SetCollection(null, new ViewTableInfoExtractUICollection(lookup.TableInfo, ViewType.TOP_100));
                f.Show();
            }
        }
Example #21
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            var uis = pDatasets.Controls.OfType <DataGeneratorUI>().Where(ui => ui.Generate).ToArray();

            if (!uis.Any())
            {
                MessageBox.Show("At least one dataset must be selected");
                return;
            }

            try
            {
                if (started)
                {
                    MessageBox.Show("Generation already in progress");
                    return;
                }

                started = true;


                var r = _seed.HasValue ? new Random(_seed.Value):new Random();


                var identifiers = new PersonCollection();
                identifiers.GeneratePeople(populationSize, r);

                if (cbLookups.Checked)
                {
                    DataGenerator.WriteLookups(_extractDirectory);
                }

                //run them at the same time
                if (!_seed.HasValue)
                {
                    foreach (DataGeneratorUI ui in uis)
                    {
                        Executing.Add(ui);
                        ui.BeginGeneration(identifiers, _extractDirectory);
                        DataGeneratorUI ui1 = ui;
                        ui.Completed += () => { Executing.Remove(ui1); AnnounceIfComplete(); };
                    }
                }
                else
                {
                    Queue <DataGeneratorUI> queue = new Queue <DataGeneratorUI>(uis);
                    Execute(identifiers, queue, queue.Dequeue(), r);
                }

                UsefulStuff.GetInstance().ShowFolderInWindowsExplorer(_extractDirectory);
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show(exception);
            }
        }
        public override void Execute()
        {
            DataTable dt = new DataTable();

            var db     = SelectOne(_loggingServers);
            var server = db.Discover(DataAccessContext.DataLoad).Server;

            if (db != null)
            {
                using (var con = server.GetConnection())
                {
                    con.Open();

                    string sql = String.Format(@"SELECT * FROM (
SELECT [dataLoadRunID]
	  ,eventType
      ,[description]
      ,[source]
      ,[time]
      ,[ID]
  FROM {0}
  {2}
UNION
SELECT [dataLoadRunID]
	  ,'OnError'
      ,[description]
      ,[source]
      ,[time]
      ,[ID]
  FROM {1}
  {2}
 ) as x
order by time ASC", LoggingTables.ProgressLog, LoggingTables.FatalError, _filter.GetWhereSql());

                    DbCommand     cmd = server.GetCommand(sql, con);
                    DbDataAdapter da  = server.GetDataAdapter(cmd);
                    da.Fill(dt);
                    StringBuilder        sb          = new StringBuilder();
                    IEnumerable <string> columnNames = dt.Columns.Cast <DataColumn>().
                                                       Select(column => column.ColumnName);
                    sb.AppendLine(string.Join(",", columnNames));

                    foreach (DataRow row in dt.Rows)
                    {
                        IEnumerable <string> fields = row.ItemArray.Select(field =>
                                                                           string.Concat("\"", field.ToString().Replace("\"", "\"\""), "\""));
                        sb.AppendLine(string.Join(",", fields));
                    }

                    var outputfile = Path.GetTempFileName() + ".csv";

                    File.WriteAllText(outputfile, sb.ToString());
                    UsefulStuff.GetInstance().ShowFileInWindowsExplorer(new FileInfo(outputfile));
                }
            }
        }
Example #23
0
        /// <summary>
        /// Deletes all data tables except <see cref="ServerDefaults"/>, <see cref="ExternalDatabaseServer"/> and some other core tables which are required for access to
        /// DQE, logging etc
        /// </summary>
        protected void BlitzMainDataTables()
        {
            using (var con = CatalogueRepository.GetConnection())
            {
                var catalogueDatabaseName  = ((TableRepository)RepositoryLocator.CatalogueRepository).DiscoveredServer.GetCurrentDatabase().GetRuntimeName();
                var dataExportDatabaseName = ((TableRepository)RepositoryLocator.DataExportRepository).DiscoveredServer.GetCurrentDatabase().GetRuntimeName();

                UsefulStuff.ExecuteBatchNonQuery(string.Format(BlitzDatabasesLite, catalogueDatabaseName, dataExportDatabaseName), con.Connection);
            }
        }
Example #24
0
        private void AddTooltip(Control c, string propertyName)
        {
            string helpText = _activator.CommentStore.GetDocumentationIfExists($"{ nameof(UserSettings)}.{propertyName}", false);

            if (string.IsNullOrWhiteSpace(helpText))
            {
                return;
            }

            userSettingsToolTips.SetToolTip(c, UsefulStuff.SplitByLength(helpText, MaxTooltipWidth));
        }
Example #25
0
 private void openExeDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         UsefulStuff.GetInstance().ShowFolderInWindowsExplorer(UsefulStuff.GetExecutableDirectory());
     }
     catch (Exception exception)
     {
         ExceptionViewer.Show(exception);
     }
 }
Example #26
0
 private void userManualToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         UsefulStuff.OpenUrl("https://github.com/HicServices/RDMP#research-data-management-platform");
     }
     catch (Exception exception)
     {
         ExceptionViewer.Show(exception);
     }
 }
Example #27
0
        private void btnShowDirectory_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbExtractionDirectory.Text))
            {
                return;
            }

            DirectoryInfo d = new DirectoryInfo(tbExtractionDirectory.Text);

            UsefulStuff.GetInstance().ShowFolderInWindowsExplorer(d);
        }
 private void btnShowDirectory_Click(object sender, EventArgs e)
 {
     try
     {
         UsefulStuff.GetInstance().ShowFileInWindowsExplorer(new FileInfo(tbCertificate.Text));
     }
     catch (Exception exception)
     {
         ExceptionViewer.Show(exception);
     }
 }
Example #29
0
 private void btnOpenContainingFolder_Click(object sender, EventArgs e)
 {
     try
     {
         UsefulStuff.GetInstance().ShowFileInWindowsExplorer(new FileInfo(tbPath.Text));
     }
     catch (Exception exception)
     {
         ExceptionViewer.Show(exception);
     }
 }
Example #30
0
 private void openExeDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         UsefulStuff.GetInstance().ShowFolderInWindowsExplorer(new DirectoryInfo(Environment.CurrentDirectory));
     }
     catch (Exception exception)
     {
         ExceptionViewer.Show(exception);
     }
 }