Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI,

I'm trying to convert :

PHP
$oTpl->newBlock("SERVER_DRIVE");
			$oTpl->assign(array(
				"DATA_DRIVE" => 'C',
				"DATA_LABEL" => $oUbb->parse($aFetchServerPagina['storage_c_label']),
				"DATA_TOTAL" => $oUbb->parse($aFetchServerPagina['storage_c_total']),
				"DATA_USED" => str_replace (',','.',$aFetchServerPagina['storage_c_used'])
			));


into C# WPF
Please help me to do this

Thanks
Jan Meeling

What I have tried:

I tried to find it in google but I don't find right results
Posted
Updated 21-Jan-21 21:38pm
v2

In C# you can create a dictionary like this:
C#
var s = new Dictionary<string, char>();

Then you can add things like
C#
s["DATA_DRIVE"] = 'C';

If your values are all strings, use StringDictionary. If the type of your values are not the same, use object.
 
Share this answer
 
v3
Comments
jan Meeling 22-Jan-21 3:53am    
Thanks for the quick response.
This is the data with it:
backup_server_data_id beheer_server_id backup_server_data_date storage_c_used storage_c_total storage_c_label storage_d_used storage_d_total storage_d_label storage_e_used storage_e_total storage_e_label storage_f_used storage_f_total storage_f_label storage_g_used storage_g_total storage_g_label
1 23 8/25/2020 13:00 24,8 80 OS 80,2 1 SFTP01 36,9 500 SFTP02
2 24 8/25/2020 13:00 24,1 80 OS 63,6 750 SFTP01 55,3 500 SFTP02
3 14 8/25/2020 13:00 56,5 80 OS 72,7 400 WSUS 18,1 200 SFTP
4 27 8/25/2020 13:00 23,1 80 OS 60,0 850 MSFTP
5 29 8/25/2020 13:00 25,5 80 OS 53,4 850 MSFTP
6 33 8/25/2020 13:00 22 100 OS 77 750 SFTP
7 34 8/25/2020 13:00 65.2 80 OS 66.9 500 SFTP

This is the code behind it:
if(strlen($aFetchServerPagina['storage_c_total']) > 0)
{
$oTpl->newBlock("SERVER_DRIVE");
$oTpl->assign(array(
"DATA_DRIVE" => 'C',
"DATA_LABEL" => $oUbb->parse($aFetchServerPagina['storage_c_label']),
"DATA_TOTAL" => $oUbb->parse($aFetchServerPagina['storage_c_total']),
"DATA_USED" => str_replace (',','.',$aFetchServerPagina['storage_c_used'])
));

if($aFetchServerPagina['storage_c_used'] > 75)
{
if($aFetchServerPagina['storage_c_used'] > 90)
{

$oTpl->newBlock("SERVER_DRIVE_CRITICAL");
$oTpl->assign(array(
"DATA_INFO" => $aFetchServerPagina['storage_c_used']
));
}
else{
$oTpl->newBlock("SERVER_DRIVE_WARNING");
$oTpl->assign(array(
"DATA_INFO" => $aFetchServerPagina['storage_c_used']
));
}
}
else{
$oTpl->newBlock("SERVER_DRIVE_OK");
$oTpl->assign(array(
"DATA_INFO" => $aFetchServerPagina['storage_c_used']
));
}
}
and it gets true to drive f
Thanks
Pete O'Hanlon 22-Jan-21 17:51pm    
My 5
The array there is just a series of Key/Value pairs so you could solve this by creating a Dictionary<string, object="">; assuming that the value in DATA_TOTAL is a number so you don't want to use a string to store this. A simpler solution is just to create a class to hold these values:
C#
public class ServerDrive
{
  public string Drive;
  public string Label;
  public int Total;
  public string Used;
}
 
Share this answer
 
Comments
jan Meeling 22-Jan-21 3:56am    
Hi Pete

Thanks for the quick response.

This is the data with it:
backup_server_data_id beheer_server_id backup_server_data_date storage_c_used storage_c_total storage_c_label storage_d_used storage_d_total storage_d_label storage_e_used storage_e_total storage_e_label storage_f_used storage_f_total storage_f_label storage_g_used storage_g_total storage_g_label
1 23 8/25/2020 13:00 24,8 80 OS 80,2 1 SFTP01 36,9 500 SFTP02
2 24 8/25/2020 13:00 24,1 80 OS 63,6 750 SFTP01 55,3 500 SFTP02
3 14 8/25/2020 13:00 56,5 80 OS 72,7 400 WSUS 18,1 200 SFTP
4 27 8/25/2020 13:00 23,1 80 OS 60,0 850 MSFTP
5 29 8/25/2020 13:00 25,5 80 OS 53,4 850 MSFTP
6 33 8/25/2020 13:00 22 100 OS 77 750 SFTP
7 34 8/25/2020 13:00 65.2 80 OS 66.9 500 SFTP

This is the code behind it:
if(strlen($aFetchServerPagina['storage_c_total']) > 0)
{
$oTpl->newBlock("SERVER_DRIVE");
$oTpl->assign(array(
"DATA_DRIVE" => 'C',
"DATA_LABEL" => $oUbb->parse($aFetchServerPagina['storage_c_label']),
"DATA_TOTAL" => $oUbb->parse($aFetchServerPagina['storage_c_total']),
"DATA_USED" => str_replace (',','.',$aFetchServerPagina['storage_c_used'])
));

if($aFetchServerPagina['storage_c_used'] > 75)
{
if($aFetchServerPagina['storage_c_used'] > 90)
{

$oTpl->newBlock("SERVER_DRIVE_CRITICAL");
$oTpl->assign(array(
"DATA_INFO" => $aFetchServerPagina['storage_c_used']
));
}
else{
$oTpl->newBlock("SERVER_DRIVE_WARNING");
$oTpl->assign(array(
"DATA_INFO" => $aFetchServerPagina['storage_c_used']
));
}
}
else{
$oTpl->newBlock("SERVER_DRIVE_OK");
$oTpl->assign(array(
"DATA_INFO" => $aFetchServerPagina['storage_c_used']
));
}
}
and it gets true to drive f
Can this done this class

This is the SQL query:
sQueryServerPagina = "SELECT *,
CONCAT(DATE_FORMAT(backup_server_data_date, '%d'), '-',
DATE_FORMAT(backup_server_data_date, '%m'), '-',
DATE_FORMAT(backup_server_data_date, '%Y'), ' ',
DATE_FORMAT(backup_server_data_date, '%H'), ':',
DATE_FORMAT(backup_server_data_date, '%i')) AS date_check
FROM
backup_server_data
INNER JOIN
beheer_servers
ON
backup_server_data.beheer_server_id = beheer_servers.beheer_servers_id";

Thanks
Christian Graus 22-Jan-21 16:23pm    
Two people have given correct answers. You should try to digest them then ask based on the things you learn

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900