-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathO2C.cs
58 lines (52 loc) · 1.93 KB
/
O2C.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
namespace SFTP_O2C
{
class O2C
{
private string _connectionString;
private SqlDataAdapter _adapter = null;
public O2C(string connectionString)
{
// Set connctionstring
_connectionString = connectionString;
// Config adapter
ConfigureAdapter(out _adapter);
// Insert, update etc
//var builder = new SqlCommandBuilder(_adapter);
}
private void ConfigureAdapter(out SqlDataAdapter adapter)
{
adapter = new SqlDataAdapter(@"
SELECT cp.cnt_email AS Email,
cp.FullName,
c.cmp_name AS Relatienaam,
LTRIM(RTRIM(c.debcode)) AS Debcode,
CONCAT('\\nasheadclst\FTP Server\FTP Klanten\', dbo.FixPath(c.cmp_name), '_', LTRIM(RTRIM(c.debcode)), '\') AS SFTP_Path
--CAST(CSNobEntPortalAccess AS bit) AS Access
FROM CSNobEntCicntp pa
INNER JOIN cicntp cp ON pa.LinkID = cp.cnt_id
INNER JOIN cicmpy c ON cp.cmp_wwn = c.cmp_wwn
WHERE cp.cnt_email IS NOT NULL
AND c.debcode IS NOT NULL
AND CAST(CSNobEntPortalAccess AS bit) = 1
AND cp.cnt_email <> 'j.bijlsma@rotaform.nl'"
, _connectionString);
}
public DataTable GetSanddwebUsers()
{
DataTable usr = new DataTable("O2CUsers");
_adapter.Fill(usr);
return usr;
}
public List<string> GetUsersAsList(DataTable dt)
{
return dt.Rows.OfType<DataRow>().Select(dr => dr.Field<string>(0)).ToList();
}
}
}