This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void SFTP_Connect_And_Download_Sample() | |
{ | |
var host = "sftp_server_address.com"; | |
var port = 999; | |
var username = "your_username"; | |
var passphrase = "your_passphrase"; | |
var privateKeyLocalFilePath = @"your_localpath\...\PrivateKeyOpenSSH.ppk"; | |
var remoteFolderPath = "/"; | |
var localFolferPath = @"D:\locafiles\"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var conn = new AdomdConnection(connectionString)) | |
{ | |
conn.Open(); | |
var commandText = @"SELECT | |
{ | |
[Measures].[Gains Period], | |
[Measures].[Gains YTD], | |
[Measures].[Amount] | |
} ON COLUMNS, | |
[Valuation Dates Accumulated].[Hierarchy].[Year].Members ON ROWS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class MyResultDTO | |
{ | |
[OLAPMemberNameAttribute("[Valuation Dates Accumulated].[Hierarchy].[Year].[MEMBER_CAPTION]")] | |
public string Year { get; set; } | |
[OLAPMemberNameAttribute("[Measures].[Gains Period]")] | |
public decimal? GainsPeriod { get; set; } | |
[OLAPMemberNameAttribute("[Measures].[Gains YTD]")] | |
public decimal? GainsYTD { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<T> Query<T>(this AdomdConnection conn, string commandText, params object[] parameters) | |
{ | |
var commandTextParameters = ReplaceCommandTextParameters(commandText, parameters); | |
var cmd = new AdomdCommand(commandTextParameters, conn); | |
var dr = cmd.ExecuteReader(); | |
return dr.ToList<T>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<T> ToList<T>(this IDataReader dr) | |
{ | |
var list = new List<T>(); | |
var obj = default(T); | |
while (dr.Read()) | |
{ | |
obj = Activator.CreateInstance<T>(); | |
foreach (var prop in obj.GetType().GetProperties()) | |
{ | |
var columnDescription = getPropertyDescription(obj, prop.Name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OLAPMemberNameAttribute : System.Attribute | |
{ | |
string _Description = string.Empty; | |
public OLAPMemberNameAttribute(string description) | |
{ | |
_Description = description; | |
} | |
public string Description { get { return _Description; } } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static TT Map<TT, ST>(this TT target, ST source) where TT : class | |
{ | |
var tprops = typeof(TT).GetProperties().Where(x => x.CanWrite).ToList(); | |
tprops.Where(x => x.CanWrite).ToList().ForEach(prop => | |
{ | |
var sp = source.GetType().GetProperty(prop.Name); | |
var tp = target.GetType().GetProperty(prop.Name); | |
if (sp != null && tp != null) | |
{ | |
var value = sp.GetValue(source, null); |