Permalink
Browse files

updated this shit

  • Loading branch information...
Bagul3 committed Jan 12, 2018
1 parent d6f4d36 commit bc82a74066aa81ffe0ec273b0ed2c684ce8edfc5
Showing with 113 additions and 31 deletions.
  1. +89 −8 StockCSV/Database.cs
  2. +22 −22 StockCSV/Mechanism/JobManager.cs
  3. +2 −1 StockCSV/Program.cs
View
@@ -37,9 +37,36 @@ private void OpenConnection(string accessConnectionPath)
}
}
public void CreateDBFFile(List<string> T2TREFs)
{
string connectionString = @"Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Users\van-d\Downloads\Cordners Data Dump\Cordners Data Dump\; Extended Properties = dBase IV";
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
connection.Open();
OleDbCommand command = connection.CreateCommand();
command.CommandText = "create table Descriptions(T2TREF int)";
command.ExecuteNonQuery();
connection.Close();
}
using (OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\van-d\Downloads\Cordners Data Dump\Cordners Data Dump\;Extended Properties=dBASE III;"))
{
connection.Open();
OleDbCommand command = connection.CreateCommand();
foreach (var t2tref in T2TREFs)
{
var sql = "Insert INTO DESCRIPT (T2TREF) VALUES ({0});";
sql = string.Format(sql, String.Format("{0:00000}", t2tref));
command.CommandText = sql;
command.ExecuteNonQuery();
}
}
}
public StringBuilder StockQuery(string reff)
{
string con = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\van-d\Downloads\Cordners Data Dump\Cordners Data Dump;Extended Properties=dBASE III;";
string con = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\van-d\Downloads\Cordners Data Dump\Cordners Data Dump\;Extended Properties=dBASE III;";
var csv = new StringBuilder();
@@ -50,19 +77,73 @@ public StringBuilder StockQuery(string reff)
var headers = string.Format("{0},{1},{2}", "sku", "qty", "is_in_stock");
csv.AppendLine(headers);
//var stockQuery = @"SELECT T2_HEAD.SHORT, T2_HEAD.[DESC], T2_HEAD.[GROUP], T2_HEAD.STYPE, T2_HEAD.SIZERANGE,
// T2_HEAD.SUPPLIER, T2_HEAD.SUPPREF, T2_HEAD.VAT, T2_HEAD.BASESELL, T2_HEAD.SELL, T2_HEAD.SELLB, T2_HEAD.SELL1, Sum(T2_BRA.Q11) AS QTY1, Sum(T2_BRA.Q12) AS QTY2,
// Sum(T2_BRA.Q13) AS QTY3, Sum(T2_BRA.Q14) AS QTY4, Sum(T2_BRA.Q15) AS QTY5, Sum(T2_BRA.Q16) AS QTY6, Sum(T2_BRA.Q17) AS QTY7, Sum(T2_BRA.Q18) AS QTY8,
// Sum(T2_BRA.Q19) AS QTY9, Sum(T2_BRA.Q20) AS QTY10, Sum(T2_BRA.Q21) AS QTY11, Sum(T2_BRA.Q22) AS QTY12, Sum(T2_BRA.Q23) AS QTY13, T2_HEAD.REF,
// Sum(T2_BRA.LY11) AS LY1, Sum(T2_BRA.LY12) AS LY2, Sum(T2_BRA.LY13) AS LY3, Sum(T2_BRA.LY14) AS LY4, Sum(T2_BRA.LY15) AS LY5,
// Sum(T2_BRA.LY16) AS LY6, Sum(T2_BRA.LY17) AS LY7, Sum(T2_BRA.LY18) AS LY8, Sum(T2_BRA.LY19) AS LY9, Sum(T2_BRA.LY20) AS LY10,
// Sum(T2_BRA.LY21) AS LY11, Sum(T2_BRA.LY22) AS LY12, Sum(T2_BRA.LY23) AS LY13
// FROM DESCRIPT INNER JOIN (T2_BRA INNER JOIN T2_HEAD ON T2_BRA.REF = T2_HEAD.REF) ON DESCRIPT.T2TREF = T2_BRA.REF
// Group By T2_HEAD.Short, T2_HEAD.[Desc], T2_HEAD.[Group], T2_HEAD.STYPE, T2_HEAD.SIZERANGE, T2_HEAD.SUPPLIER, T2_HEAD.SUPPREF, T2_HEAD.VAT, T2_HEAD.BASESELL, T2_HEAD.SELL, T2_HEAD.SELLB, T2_HEAD.SELL1, T2_HEAD.REF";
//var stockQuery = @"SELECT T2_HEAD.SHORT,
//T2_HEAD.[DESC], T2_HEAD.[GROUP], T2_HEAD.STYPE,
//T2_HEAD.SIZERANGE, T2_HEAD.SUPPLIER, T2_HEAD.SUPPREF, T2_HEAD.VAT, T2_HEAD.BASESELL,
// T2_HEAD.SELL, T2_HEAD.SELLB, T2_HEAD.SELL1,
//Sum(T2_BRA.Q11) AS SumOfQ11,
//Sum(T2_BRA.Q12) AS SumOfQ12,
//Sum(T2_BRA.Q13) AS SumOfQ13,
//Sum(T2_BRA.Q14) AS SumOfQ14,
//Sum(T2_BRA.Q15) AS SumOfQ15,
//Sum(T2_BRA.Q16) AS SumOfQ16,
//Sum(T2_BRA.Q17) AS SumOfQ17,
//Sum(T2_BRA.Q18) AS SumOfQ18,
//Sum(T2_BRA.Q19) AS SumOfQ19,
//Sum(T2_BRA.Q20) AS SumOfQ20,
//Sum(T2_BRA.Q21) AS SumOfQ21,
//Sum(T2_BRA.Q22) AS SumOfQ22,
//Sum(T2_BRA.Q23) AS SumOfQ23,
//Sum(T2_BRA.LY11) AS SumOfLY11,
//Sum(T2_BRA.LY12) AS SumOfLY12,
//Sum(T2_BRA.LY13) AS SumOfLY13,
//Sum(T2_BRA.LY14) AS SumOfLY14,
//Sum(T2_BRA.LY15) AS SumOfLY15,
//Sum(T2_BRA.LY16) AS SumOfLY16,
//Sum(T2_BRA.LY17) AS SumOfLY17,
//Sum(T2_BRA.LY18) AS SumOfLY18,
//Sum(T2_BRA.LY19) AS SumOfLY19,
//Sum(T2_BRA.LY20) AS SumOfLY20,
//Sum(T2_BRA.LY21) AS SumOfLY21,
//Sum(T2_BRA.LY22) AS SumOfLY22,
//Sum(T2_BRA.LY23) AS SumOfLY23
//FROM DESCRIPT INNER JOIN (T2_BRA INNER JOIN T2_HEAD ON T2_BRA.REF = T2_HEAD.REF)
//ON DESCRIPT.T2TREF = T2_BRA.REF
//Group By T2_HEAD.Short, T2_HEAD.[Desc], T2_HEAD.[Group], T2_HEAD.STYPE, T2_HEAD.SIZERANGE, T2_HEAD.SUPPLIER, T2_HEAD.SUPPREF,
//T2_HEAD.VAT, T2_HEAD.BASESELL, T2_HEAD.SELL, T2_HEAD.SELLB, T2_HEAD.SELL1";
var stockQuery = @"SELECT T2_HEAD.SHORT, T2_HEAD.[DESC], T2_HEAD.[GROUP], T2_HEAD.STYPE, T2_HEAD.SIZERANGE,
T2_HEAD.SUPPLIER, T2_HEAD.SUPPREF, T2_HEAD.VAT, T2_HEAD.BASESELL, T2_HEAD.SELL, T2_HEAD.SELLB, T2_HEAD.SELL1, Sum(T2_BRA.Q11) AS QTY1, Sum(T2_BRA.Q12) AS QTY2,
Sum(T2_BRA.Q13) AS QTY3, Sum(T2_BRA.Q14) AS QTY4, Sum(T2_BRA.Q15) AS QTY5, Sum(T2_BRA.Q16) AS QTY6, Sum(T2_BRA.Q17) AS QTY7, Sum(T2_BRA.Q18) AS QTY8,
Sum(T2_BRA.Q19) AS QTY9, Sum(T2_BRA.Q20) AS QTY10, Sum(T2_BRA.Q21) AS QTY11, Sum(T2_BRA.Q22) AS QTY12, Sum(T2_BRA.Q23) AS QTY13, T2_HEAD.REF,
Sum(T2_BRA.LY11) AS LY1, Sum(T2_BRA.LY12) AS LY2, Sum(T2_BRA.LY13) AS LY3, Sum(T2_BRA.LY14) AS LY4, Sum(T2_BRA.LY15) AS LY5,
Sum(T2_BRA.LY16) AS LY6, Sum(T2_BRA.LY17) AS LY7, Sum(T2_BRA.LY18) AS LY8, Sum(T2_BRA.LY19) AS LY9, Sum(T2_BRA.LY20) AS LY10,
Sum(T2_BRA.LY21) AS LY11, Sum(T2_BRA.LY22) AS LY12, Sum(T2_BRA.LY23) AS LY13
FROM T2_BRA INNER JOIN T2_HEAD ON T2_BRA.REF = T2_HEAD.REF WHERE T2_BRA.REF = ?
Group By T2_HEAD.Short, T2_HEAD.[Desc], T2_HEAD.[Group], T2_HEAD.STYPE, T2_HEAD.SIZERANGE, T2_HEAD.SUPPLIER, T2_HEAD.SUPPREF, T2_HEAD.VAT, T2_HEAD.BASESELL, T2_HEAD.SELL, T2_HEAD.SELLB, T2_HEAD.SELL1, T2_HEAD.REF";
FROM DESCRIPT INNER JOIN (T2_BRA INNER JOIN T2_HEAD ON T2_BRA.REF = T2_HEAD.REF) ON DESCRIPT.T2TREF = T2_BRA.REF
Group By T2_HEAD.Short, T2_HEAD.[Desc], T2_HEAD.[Group], T2_HEAD.STYPE, T2_HEAD.SIZERANGE,
T2_HEAD.SUPPLIER, T2_HEAD.SUPPREF, T2_HEAD.VAT, T2_HEAD.BASESELL, T2_HEAD.SELL, T2_HEAD.SELLB, T2_HEAD.SELL1, T2_HEAD.REF";
//var stockQuery = @"SELECT * FROM DESCRIPT ";
//var stockQuery = @"SELECT ([T2_BRA]![REF] & [F7]) AS NEWSTYLE, T2_HEAD.SHORT, T2_HEAD.DESC, T2_HEAD.GROUP, T2_HEAD.STYPE, T2_HEAD.SIZERANGE, T2_HEAD.SUPPLIER, T2_HEAD.SUPPREF, T2_HEAD.VAT, T2_HEAD.BASESELL, T2_HEAD.SELL, T2_HEAD.SELLB, T2_HEAD.SELL1, Sum(T2_BRA.Q11) AS SumOfQ11, Sum(T2_BRA.Q12) AS SumOfQ12, Sum(T2_BRA.Q13) AS SumOfQ13, Sum(T2_BRA.Q14) AS SumOfQ14, Sum(T2_BRA.Q15) AS SumOfQ15, Sum(T2_BRA.Q16) AS SumOfQ16, Sum(T2_BRA.Q17) AS SumOfQ17, Sum(T2_BRA.Q18) AS SumOfQ18, Sum(T2_BRA.Q19) AS SumOfQ19, Sum(T2_BRA.Q20) AS SumOfQ20, Sum(T2_BRA.Q21) AS SumOfQ21, Sum(T2_BRA.Q22) AS SumOfQ22, Sum(T2_BRA.Q23) AS SumOfQ23, T2_HEAD.REF,
// Sum(T2_BRA.LY11) AS SumOfLY11, Sum(T2_BRA.LY12) AS SumOfLY12, Sum(T2_BRA.LY13) AS SumOfLY13, Sum(T2_BRA.LY14) AS SumOfLY14, Sum(T2_BRA.LY15) AS SumOfLY15, Sum(T2_BRA.LY16) AS SumOfLY16, Sum(T2_BRA.LY17) AS SumOfLY17, Sum(T2_BRA.LY18) AS SumOfLY18, Sum(T2_BRA.LY19) AS SumOfLY19, Sum(T2_BRA.LY20) AS SumOfLY20, Sum(T2_BRA.LY21) AS SumOfLY21, Sum(T2_BRA.LY22) AS SumOfLY22, Sum(T2_BRA.LY23) AS SumOfLY23
// FROM DESCRIPT INNER JOIN (T2_BRA INNER JOIN T2_HEAD ON T2_BRA.REF = T2_HEAD.REF) ON DESCRIPT.T2TREF = T2_BRA.REF
// Group By([T2_BRA]![REF] & [F7]), T2_HEAD.Short, T2_HEAD.Desc, T2_HEAD.Group, T2_HEAD.STYPE, T2_HEAD.SIZERANGE, T2_HEAD.SUPPLIER, T2_HEAD.SUPPREF, T2_HEAD.VAT, T2_HEAD.BASESELL, T2_HEAD.SELL, T2_HEAD.SELLB, T2_HEAD.SELL1, T2_HEAD.REF
// ORDER BY ([T2_BRA]![REF] & [F7]) DESC;";
DataSet data = new DataSet();
OleDbCommand myAccessCommand = new OleDbCommand(stockQuery, connectionHandler);
myAccessCommand.Parameters.AddWithValue("?", reff);
//myAccessCommand.Parameters.AddWithValue("?", reff);
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(myAccessCommand);
myDataAdapter.Fill(data);
@@ -73,7 +154,7 @@ public StringBuilder StockQuery(string reff)
var GroupSKUS = "";
var salesPrice = "";
foreach (DataRow dr in data.Tables[0].Rows)
foreach (DataRow dr in data.Tables[0].Rows)
{
for (var i = 1; i < 14; i++)
{
@@ -131,14 +212,14 @@ public StringBuilder StockQuery(string reff)
}
}
//File.AppendAllText(@"C:\Users\van-d\Documents\stock.csv", csv.ToString());
return csv;
File.AppendAllText(@"C:\Users\van-d\Documents\stocknew.csv", csv.ToString());
return null;
}
public List<string> QueryDescriptionXLX()
{
var query = "Select T2TREF FROM";
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\van-d\Downloads\Cordners Data Dump\Cordners Data Dump\descriptions.xls;Extended Properties='Excel 12.0;IMEX=1;'");
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\van-d\Downloads\Cordners Data Dump\descriptions.xls;Extended Properties='Excel 12.0;IMEX=1;'");
StringBuilder stbQuery = new StringBuilder();
stbQuery.Append("SELECT * FROM [Sheet1$A:A]");
OleDbDataAdapter adp = new OleDbDataAdapter(stbQuery.ToString(), con);
@@ -30,28 +30,28 @@ public void ExecuteAllJobs()
if (jobs != null && jobs.Any())
{
foreach (var job in jobs)
{
if (IsRealClass(job))
{
try
{
var instanceJob = Activator.CreateInstance(job);
Console.WriteLine($"The Job \"{instanceJob.GetEndpoint()}\" has been instantiated successfully.");
var thread = new Thread(instanceJob.ExecuteJob);
thread.Start();
Console.WriteLine($"The Job \"{instanceJob.GetEndpoint()}\" has its thread started successfully.");
}
catch (Exception ex)
{
Console.WriteLine($"The Job \"{job.GetRef()}\" could not be instantiated or executed.", ex);
}
}
else
{
Console.WriteLine($"The Job \"{job.GetRef()}\" cannot be instantiated.");
}
}
//foreach (var job in jobs)
//{
// if (IsRealClass(job))
// {
// try
// {
// ///var instanceJob = Activator.CreateInstance(job);
// Console.WriteLine($"The Job \"{instanceJob.GetEndpoint()}\" has been instantiated successfully.");
// var thread = new Thread(instanceJob.ExecuteJob);
// thread.Start();
// Console.WriteLine($"The Job \"{instanceJob.GetEndpoint()}\" has its thread started successfully.");
// }
// catch (Exception ex)
// {
// Console.WriteLine($"The Job \"{job.GetRef()}\" could not be instantiated or executed.", ex);
// }
// }
// else
// {
// Console.WriteLine($"The Job \"{job.GetRef()}\" cannot be instantiated.");
// }
//}
}
}
catch (Exception ex)
View
@@ -13,7 +13,8 @@ static void Main(string[] args)
Database database = new Database();
var result = database.QueryDescriptionXLX();
database = new Database(@"C:\Users\van-d\Downloads\Cordners Data Dump\Cordners Data Dump\");
database.StockQuery(result);
database.CreateDBFFile(result);
database.StockQuery("");
}
}
}

0 comments on commit bc82a74

Please sign in to comment.