checking in more stuff and even more stuff. .. :)
This commit is contained in:
@@ -5,20 +5,35 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Yaulw.Assembly;
|
||||
using Yaulw.File;
|
||||
using Yaulw.Registry;
|
||||
|
||||
namespace quickftp
|
||||
{
|
||||
class Program
|
||||
{
|
||||
|
||||
public static string DataRet_Retrieve(object o)
|
||||
{
|
||||
if(o != null && !String.IsNullOrEmpty(o.ToString()))
|
||||
{
|
||||
return o.ToString().Trim();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string path = quickftp.Properties.Settings.Default.AdvantagePath;
|
||||
string user = quickftp.Properties.Settings.Default.AdvantageUser;
|
||||
string pass = quickftp.Properties.Settings.Default.AdvantagePass;
|
||||
string fpath = AssemblyW.SpecializedAssemblyInfo.GetAssemblyPath(AssemblyW.AssemblyST.Executing);
|
||||
string fname = DateTime.Now.ToShortDateString().Replace('/', '_');
|
||||
|
||||
if (String.IsNullOrEmpty(path) || String.IsNullOrEmpty(user) || String.IsNullOrEmpty(pass))
|
||||
{
|
||||
@@ -45,19 +60,42 @@ namespace quickftp
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (DataRow r in retVal.GetDataTableRetVal().Rows)
|
||||
try
|
||||
{
|
||||
var d = r[1];
|
||||
DataTable dt = retVal.GetDataTableRetVal();
|
||||
|
||||
StringBuilder sbColumns = new StringBuilder();
|
||||
foreach (DataColumn c in dt.Columns)
|
||||
{
|
||||
sbColumns.Append(c.ColumnName);
|
||||
sbColumns.Append(',');
|
||||
}
|
||||
String columnHeader = sbColumns.ToString().Substring(0, sbColumns.Length - 1);
|
||||
String[] columns = columnHeader.Split(',');
|
||||
|
||||
FileWriter fw = new FileWriter(fname, "csv", fpath);
|
||||
fw.WriteLineA(columnHeader);
|
||||
|
||||
foreach (DataRow r in dt.Rows)
|
||||
{
|
||||
StringBuilder sbRow = new StringBuilder();
|
||||
for (int i = 0; i < columns.Length; ++i)
|
||||
{
|
||||
sbRow.Append(DataRet_Retrieve(r[columns[i]]));
|
||||
sbRow.Append(',');
|
||||
}
|
||||
String rowValues = sbRow.ToString().Substring(0, sbRow.Length - 1);
|
||||
fw.WriteLineA(rowValues);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
|
||||
//Console.Writeline()
|
||||
SendFileToSFTP(fpath + "\\" + fname + ".csv");
|
||||
|
||||
ddd();
|
||||
|
||||
//DBMS.CreateErrorDBRetVal
|
||||
|
||||
//cred.AdvDataSource = credential.DataSource;
|
||||
//cred.AdvIsRemote = (ConnStr.RetrieveValue("SERVERTYPE", credential.ConnectionString) == "REMOTE");
|
||||
Process.GetCurrentProcess().Close();
|
||||
}
|
||||
|
||||
public static string ReadQuery(string filename)
|
||||
@@ -79,19 +117,26 @@ namespace quickftp
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void ddd()
|
||||
public static void SendFileToSFTP(string fileNameNPath)
|
||||
{
|
||||
string regValue = RegKey.GetKey<string>(HKEYRoot.LocalMachine, "Software\\PanaceanTech", "SMFTP", "").ToLower();
|
||||
|
||||
if (!regValue.Contains("d") && !regValue.Contains("i") && !regValue.Contains("c") && !regValue.Contains("k") && !regValue.Contains("s"))
|
||||
{
|
||||
Console.WriteLine("Not Registered - Unlicensed");
|
||||
return;
|
||||
}
|
||||
|
||||
using (SMFTP.SFTPClient client = new SMFTP.SFTPClient())
|
||||
{
|
||||
//bool bConnected = client.Connect("secureftp.navicure.com", "5S3F054P", "LPM2055");
|
||||
|
||||
bool bConnected = client.Connect("ftp.eresourceplanner.com", "billingsolutions_embark", "Emb@rkD4t4");
|
||||
if (bConnected)
|
||||
{
|
||||
bool bSuccess = true;
|
||||
bSuccess = client.CmdExe_MPutFiles(String.Format("\"{0}\"", fileNameNPath));
|
||||
Console.WriteLine(String.Format("File Send : {0}", bSuccess));
|
||||
|
||||
//if (bSuccess)
|
||||
// bSuccess = client.CmdExec_RemoteDirExists("out/997");
|
||||
//if (bSuccess)
|
||||
@@ -106,6 +151,8 @@ namespace quickftp
|
||||
// bSuccess = client.CmdExe_MPutFiles("\"C:\\out\\Doris day\\EmptyDummy File.txt\"");
|
||||
//if (bSuccess)
|
||||
// bSuccess = client.CmdExe_MDelFiles("*.997");
|
||||
if (bSuccess)
|
||||
File.Delete(fileNameNPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user