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
log.Debug("GetConfigValues ==> ");
try
{
string DatabaseName = _appSettings.ConnectionString;
_appSettings.ConnectionString = _appSettings.AdminConnectionString;
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<ConfigValues>? RequestsList = adapter.ConfigValues(CompanyId);
List<ConfigValues>? RequestsList = adapter.ConfigValues(CompanyId,DatabaseName);
return Ok(RequestsList);
}
catch (Exception ex)
......@@ -271,18 +272,18 @@ namespace FTP_Services.Services.Controllers
}
[HttpPost("DownloadBase64DataAsync")]
public async Task<string> DownloadBase64DataAsync(string fileNameWithPath)
public async Task<string> DownloadBase64DataAsync(string fileNameWithPath,bool IsExternal)
{
bool isFTPMODE = _appSettings.FTPConfiguration.FTPMODE;
var base64 = string.Empty;
if (isFTPMODE == true)
if (IsExternal == true)
{
int bytesRead;
// byte[] buffer = new byte[2048];
byte[] buffer = new byte[1048576]; // 1 MB buffer
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 FTPPassword = _appSettings.FTPConfiguration.Password.ToString();
......@@ -319,7 +320,7 @@ namespace FTP_Services.Services.Controllers
else
{
string strDestinationPath = _appSettings
.FTPConfiguration.DestinationPath.ToString()
.FTPConfiguration.DestinationPathFile.ToString()
.Trim();
string strFullPath = Path.Combine(strDestinationPath, fileNameWithPath);
if (string.IsNullOrEmpty(strFullPath) || !System.IO.File.Exists(strFullPath))
......
......@@ -23,6 +23,8 @@ namespace FTP_Services.Core.Models
public string FtpURL { get; set; }
public bool FTPMODE { get; set; }
public string DestinationPath { get; set; }
public string DestinationPathFtp { get; set; }
public string DestinationPathFile { get; set; }
public FTPConfiguration()
{
......
......@@ -152,6 +152,7 @@ namespace FTP_Services.Core.Models
public string DefaultDocType { get; set; }
public bool IsActive { get; set; }
public int CompanyId { get; set; }
public string DatabaseName { get; set; }
public ConfigValues()
{
......@@ -165,6 +166,7 @@ namespace FTP_Services.Core.Models
DefaultDocType ="";
IsActive = true;
CompanyId= 1;
DatabaseName ="";
}
}
......@@ -188,6 +190,7 @@ namespace FTP_Services.Core.Models
public string DocumentUrl { get; set; }
public int SplID { get; set; }
public string ThumbnailUrl { get; set; }
public bool IsExternal { get; set; }
public PatientDocuments()
......@@ -210,6 +213,7 @@ namespace FTP_Services.Core.Models
DocumentUrl = "";
SplID = -1;
ThumbnailUrl ="";
IsExternal =false;
}
}
......
......@@ -138,7 +138,7 @@ if (app.Environment.IsDevelopment())
}
else
{
//app.Run();
//app.Run(); //For Test Site
app.Run("http://*:4708"); // For Production
//app.Run("http://*:4709"); // For Admin
......
......@@ -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;
try
{
using (var tx = _repository.GetTransaction())
{
ConfigValuesData = _repository.Fetch<ConfigValues>(
"SELECT * FROM \"SPScanTool_GetScanConfigByCompanyId\"(@0)", CompanyId
"SELECT '" + DatabaseName + "' AS \"DatabaseName\", * FROM \"SPScanTool_GetScanConfigByCompanyId\"(@0)", CompanyId
);
GC.Collect();
......
......@@ -2,23 +2,23 @@
"AppSettings": {
"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",
"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": {
"Username": "fernandez",
"Password": "fernandez123!",
"FtpURL": "ftp://192.168.7.104/",
"Username": "admin",
"Password": "Fmh@xp@rt01",
"FtpURL": "ftp://183.82.47.232/",
"FTPMODE": false,
"DestinationPath": "/ftproot/FTPRoot/"
"DestinationPathFile": "/ftproot/FTPRoot/",
"DestinationPathFtp": "/apachetomcat/webapps/documents/"
}
},
"https_port": 8001,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
},
"https_port": 8001,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"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