Search This Blog

Configure Serenity with Oracle 19c


  • First establish a development environment to run serenity without oracle. For this install VS 2019, .NET Core 3.1 SDK, NodeJS, Typescript, Serene Template.
  • Then install oracle19c, toad (optional). Also create a schema "mov" using the following code.

CREATE USER MOV
  IDENTIFIED BY "Mov123"
  HTTP DIGEST DISABLE
  DEFAULT TABLESPACE USERS
  TEMPORARY TABLESPACE TEMP
  PROFILE DEFAULT
  ACCOUNT UNLOCK;

-- 6 System Privileges for MOV
GRANT CREATE ANY SYNONYM TO MOV;
GRANT CREATE ANY TABLE TO MOV;
GRANT CREATE ANY TRIGGER TO MOV;
GRANT CREATE SEQUENCE TO MOV;
GRANT CREATE SESSION TO MOV;
GRANT UNLIMITED TABLESPACE TO MOV;



  • Copy modified sergen for orale from below link and place it in d drive

https://drive.google.com/file/d/1tLX7zzBOTKZQa49mZs4npWEcEAySM9ij/view


  • From Visual Stdio, click Tools => NuGet Package Manager => Manage NuGet Packages for Solution
Now, in the browse tab, search "Oracle.ManagedDataAccess.Core" and install it.


  •  add replace this line in file startup.cs

DbProviderFactories.RegisterFactory("Microsoft.Data.Sqlite", Microsoft.Data.Sqlite.SqliteFactory.Instance);

with this line

DbProviderFactories.RegisterFactory("Oracle.ManagedDataAccess.Client",  Oracle.ManagedDataAccess.Client.OracleClientFactory.Instance);

  • Edit connection string in file appsettings.json by replacing the following code,

"Default": {
      "ConnectionString": "Server=(localdb)\\MsSqlLocalDB;Database=Serene7_Default_v1;Integrated Security=true",
      "ProviderName": "System.Data.SqlClient"
    },

with




"Default": { 

"ConnectionString": "User Id=mov;password=Mov123;Data Source=localhost:1521/db19c;",
"ProviderName": "Oracle.ManagedDataAccess.Client"
},



where "mov" is the schema we created in oracle. and db19c is the global database name



  • Edit this file \Project.Web\Modules\Administration\Sergen\SergenEndpoint.cs 

replace the below the below function

private void RunSergen(params string[] arguments)
        {
            var process = Process.Start(new ProcessStartInfo
            {
                FileName = "dotnet",
                CreateNoWindow = true,
                Arguments = "sergen " + string.Join(" ", arguments)
            });

            if (!process.WaitForExit(90000) || process.ExitCode != 0)
                throw new ValidationError("Error while running Sergen!");

        }

with,

private void RunSergen(params string[] arguments)
        {
            var process = Process.Start(new ProcessStartInfo
            {
                FileName = @"D:\sergen\net461\dotnet-sergen.exe",
                CreateNoWindow = true,
                Arguments = string.Join(" ", arguments)
            });

            if (!process.WaitForExit(90000) || process.ExitCode != 0)

                throw new ValidationError("Error while running Sergen!");

        }

and replace the below the below function 
private TOut RunSergen<TOut>(params string[] arguments)
        {
            var tempFile = System.IO.Path.GetTempFileName() + ".json";
            try
            {
                var process = Process.Start(new ProcessStartInfo
                {
                    FileName = "dotnet",
                    CreateNoWindow = true,
                    WorkingDirectory = hostingEnvironment.ContentRootPath,
                    Arguments = "sergen " + string.Join(" ", arguments) + " -o " + Escape(tempFile)
                });

                if (!process.WaitForExit(90000) || process.ExitCode != 0)
                    throw new ValidationError("Error while running Sergen!");

                return JSON.ParseTolerant<TOut>(System.IO.File.ReadAllText(tempFile));
            }
            finally
            {
                System.IO.File.Delete(tempFile);
            }

        }

with,
       
private TOut RunSergen<TOut>(params string[] arguments)
        {
            var tempFile = System.IO.Path.GetTempFileName() + ".json";
            try
            {
                var process = Process.Start(new ProcessStartInfo
                {
                    FileName = @"D:\sergen\net461\dotnet-sergen.exe",
                    CreateNoWindow = true,
                    WorkingDirectory = hostingEnvironment.ContentRootPath,
                    Arguments = string.Join(" ", arguments) + " -o " + Escape(tempFile)
                });
                if (!process.WaitForExit(90000) || process.ExitCode != 0)
                    throw new ValidationError("Error while running Sergen!");
                return JSON.ParseTolerant<TOut>(System.IO.File.ReadAllText(tempFile));
            }
            finally
            {
                System.IO.File.Delete(tempFile);
            }
        }

  • now build and run the solution

No comments:

Post a Comment

Web Statistics