Commit f3a3819a authored by Krishna Reddy Tamatam's avatar Krishna Reddy Tamatam

For Ftp And Config Changes

parent ebc733b2
...@@ -156,9 +156,10 @@ namespace FTP_Services.Services.Controllers ...@@ -156,9 +156,10 @@ namespace FTP_Services.Services.Controllers
log.Debug("GetConfigValues ==> "); log.Debug("GetConfigValues ==> ");
try try
{ {
string DatabaseName = _appSettings.ConnectionString;
_appSettings.ConnectionString = _appSettings.AdminConnectionString; _appSettings.ConnectionString = _appSettings.AdminConnectionString;
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings); FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<ConfigValues>? RequestsList = adapter.ConfigValues(CompanyId); List<ConfigValues>? RequestsList = adapter.ConfigValues(CompanyId,DatabaseName);
return Ok(RequestsList); return Ok(RequestsList);
} }
catch (Exception ex) catch (Exception ex)
...@@ -271,18 +272,18 @@ namespace FTP_Services.Services.Controllers ...@@ -271,18 +272,18 @@ namespace FTP_Services.Services.Controllers
} }
[HttpPost("DownloadBase64DataAsync")] [HttpPost("DownloadBase64DataAsync")]
public async Task<string> DownloadBase64DataAsync(string fileNameWithPath) public async Task<string> DownloadBase64DataAsync(string fileNameWithPath,bool IsExternal)
{ {
bool isFTPMODE = _appSettings.FTPConfiguration.FTPMODE; bool isFTPMODE = _appSettings.FTPConfiguration.FTPMODE;
var base64 = string.Empty; var base64 = string.Empty;
if (isFTPMODE == true) if (IsExternal == true)
{ {
int bytesRead; int bytesRead;
// byte[] buffer = new byte[2048]; // byte[] buffer = new byte[2048];
byte[] buffer = new byte[1048576]; // 1 MB buffer byte[] buffer = new byte[1048576]; // 1 MB buffer
byte[] fileData = null; byte[] fileData = null;
string FTPURL = _appSettings.FTPConfiguration.FtpURL.ToString(); string FTPURL = _appSettings.FTPConfiguration.FtpURL.ToString() + '/' + _appSettings.FTPConfiguration.DestinationPathFtp.ToString();
string FTPUserName = _appSettings.FTPConfiguration.Username.ToString(); string FTPUserName = _appSettings.FTPConfiguration.Username.ToString();
string FTPPassword = _appSettings.FTPConfiguration.Password.ToString(); string FTPPassword = _appSettings.FTPConfiguration.Password.ToString();
...@@ -319,7 +320,7 @@ namespace FTP_Services.Services.Controllers ...@@ -319,7 +320,7 @@ namespace FTP_Services.Services.Controllers
else else
{ {
string strDestinationPath = _appSettings string strDestinationPath = _appSettings
.FTPConfiguration.DestinationPath.ToString() .FTPConfiguration.DestinationPathFile.ToString()
.Trim(); .Trim();
string strFullPath = Path.Combine(strDestinationPath, fileNameWithPath); string strFullPath = Path.Combine(strDestinationPath, fileNameWithPath);
if (string.IsNullOrEmpty(strFullPath) || !System.IO.File.Exists(strFullPath)) if (string.IsNullOrEmpty(strFullPath) || !System.IO.File.Exists(strFullPath))
......
...@@ -23,6 +23,8 @@ namespace FTP_Services.Core.Models ...@@ -23,6 +23,8 @@ namespace FTP_Services.Core.Models
public string FtpURL { get; set; } public string FtpURL { get; set; }
public bool FTPMODE { get; set; } public bool FTPMODE { get; set; }
public string DestinationPath { get; set; } public string DestinationPath { get; set; }
public string DestinationPathFtp { get; set; }
public string DestinationPathFile { get; set; }
public FTPConfiguration() public FTPConfiguration()
{ {
......
...@@ -152,6 +152,7 @@ namespace FTP_Services.Core.Models ...@@ -152,6 +152,7 @@ namespace FTP_Services.Core.Models
public string DefaultDocType { get; set; } public string DefaultDocType { get; set; }
public bool IsActive { get; set; } public bool IsActive { get; set; }
public int CompanyId { get; set; } public int CompanyId { get; set; }
public string DatabaseName { get; set; }
public ConfigValues() public ConfigValues()
{ {
...@@ -165,6 +166,7 @@ namespace FTP_Services.Core.Models ...@@ -165,6 +166,7 @@ namespace FTP_Services.Core.Models
DefaultDocType =""; DefaultDocType ="";
IsActive = true; IsActive = true;
CompanyId= 1; CompanyId= 1;
DatabaseName ="";
} }
} }
...@@ -188,6 +190,7 @@ namespace FTP_Services.Core.Models ...@@ -188,6 +190,7 @@ namespace FTP_Services.Core.Models
public string DocumentUrl { get; set; } public string DocumentUrl { get; set; }
public int SplID { get; set; } public int SplID { get; set; }
public string ThumbnailUrl { get; set; } public string ThumbnailUrl { get; set; }
public bool IsExternal { get; set; }
public PatientDocuments() public PatientDocuments()
...@@ -210,6 +213,7 @@ namespace FTP_Services.Core.Models ...@@ -210,6 +213,7 @@ namespace FTP_Services.Core.Models
DocumentUrl = ""; DocumentUrl = "";
SplID = -1; SplID = -1;
ThumbnailUrl =""; ThumbnailUrl ="";
IsExternal =false;
} }
} }
......
...@@ -138,7 +138,7 @@ if (app.Environment.IsDevelopment()) ...@@ -138,7 +138,7 @@ if (app.Environment.IsDevelopment())
} }
else else
{ {
//app.Run(); //app.Run(); //For Test Site
app.Run("http://*:4708"); // For Production app.Run("http://*:4708"); // For Production
//app.Run("http://*:4709"); // For Admin //app.Run("http://*:4709"); // For Admin
......
...@@ -155,15 +155,36 @@ namespace FTP_Services.Services ...@@ -155,15 +155,36 @@ namespace FTP_Services.Services
// } // }
// } // }
public List<ConfigValues>? ConfigValues(int CompanyId) public string GetDatabaseNameFromConnectionString(string connectionString)
{ {
// Split connection string by ';'
var parameters = connectionString.Split(';', StringSplitOptions.RemoveEmptyEntries);
foreach (var param in parameters)
{
// Check if the parameter starts with 'Database=' (case-insensitive)
if (param.StartsWith("Database=", StringComparison.OrdinalIgnoreCase))
{
// Return the value after 'Database='
return param.Split('=')[1];
}
}
// Return a default message if not found
return "Database name not found!";
}
public List<ConfigValues>? ConfigValues(int CompanyId, string StrConnection)
{
string DatabaseName = GetDatabaseNameFromConnectionString(StrConnection);
List<ConfigValues>? ConfigValuesData = null; List<ConfigValues>? ConfigValuesData = null;
try try
{ {
using (var tx = _repository.GetTransaction()) using (var tx = _repository.GetTransaction())
{ {
ConfigValuesData = _repository.Fetch<ConfigValues>( ConfigValuesData = _repository.Fetch<ConfigValues>(
"SELECT * FROM \"SPScanTool_GetScanConfigByCompanyId\"(@0)", CompanyId "SELECT '" + DatabaseName + "' AS \"DatabaseName\", * FROM \"SPScanTool_GetScanConfigByCompanyId\"(@0)", CompanyId
); );
GC.Collect(); GC.Collect();
......
...@@ -2,23 +2,23 @@ ...@@ -2,23 +2,23 @@
"AppSettings": { "AppSettings": {
"Secret": "A78E-F7FA-B0FD-DAA45BB866CD-AA73D560-DACC-978C-4A9B-9924-5DE7E33F0040-GCD00", "Secret": "A78E-F7FA-B0FD-DAA45BB866CD-AA73D560-DACC-978C-4A9B-9924-5DE7E33F0040-GCD00",
"ConnectionString": "SERVER=10.11.12.106;PORT=5432;UID=himsdbuser;PWD=dbuser@hims123!;database=fernandez_20241125;Timeout=1000", "ConnectionString": "SERVER=10.11.12.106;PORT=5432;UID=himsdbuser;PWD=dbuser@hims123!;database=fernandez_20241125;Timeout=1000",
"AdminConnectionString": "SERVER=10.11.12.106;PORT=5432;UID=himsdbuser;PWD=dbuser@hims123!;database=CareaxesAdmin;Timeout=1000", "AdminConnectionString": "SERVER=10.11.12.106;PORT=5432;UID=himsdbuser;PWD=dbuser@hims123!;database=fernandez_20241125;Timeout=1000",
"FTPConfiguration": { "FTPConfiguration": {
"Username": "fernandez", "Username": "admin",
"Password": "fernandez123!", "Password": "Fmh@xp@rt01",
"FtpURL": "ftp://192.168.7.104/", "FtpURL": "ftp://183.82.47.232/",
"FTPMODE": false, "FTPMODE": false,
"DestinationPath": "/ftproot/FTPRoot/" "DestinationPathFile": "/ftproot/FTPRoot/",
"DestinationPathFtp": "/apachetomcat/webapps/documents/"
} }
}, },
"https_port": 8001, "https_port": 8001,
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",
"Microsoft": "Warning", "Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information" "Microsoft.Hosting.Lifetime": "Information"
} }
}, },
"AllowedHosts": "*" "AllowedHosts": "*"
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment