static void Log(string msg) { string msgCons = String.Format("[{0}] {1}", CUtilTime.GetDateTimeString(DateTime.Now), msg); Console.WriteLine(msgCons); }
static void Main(string[] args) { //upd 2018-04-22 if (args.Length < 1) { Console.WriteLine("Invalid arguments. Usage: "); Console.WriteLine("MySQLDumper DATABASE_NAME"); return; } string dbName = args[0]; Process proc = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); string path = Environment.GetEnvironmentVariable("DB_BACKUPS_PATH"); string tm = CUtilTime.GeDateString(DateTime.Now); string dirName = String.Format("{0}\\{1}\\{2}\\{3}", path, DateTime.Now.Year.ToString("D4"), DateTime.Now.Month.ToString("D2"), tm); CUtil.CreateDirIfNotExist(dirName); if (Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } string tmCurrent = CUtilTime.GetDateTimeString(DateTime.Now); string fname = String.Format("{0}\\fulldump_{1}.sql", dirName, tmCurrent); startInfo.FileName = @"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe"; startInfo.Arguments = String.Format(@"--user=root --password=profinvest --routines --complete-insert {0} --result-file {1}", dbName, fname); proc.StartInfo = startInfo; proc.Start(); }
public void Test() { CBitfenixWebSockConnector bfxWebSock = new CBitfenixWebSockConnector(this, GenListInstrument(), true, "fVgyf0Rk4hDDDdXAzys7yN0vnGcRPUVYRTLoOxTyDIL", "MDqroztPvZzFIaKKspozdyeAD274OFAZnEZy2nv3eUE"); ThreadPool.SetMinThreads(100, 100); // System.Threading.Thread.Sleep(60000); //string path = @"e:\ATFS\Logs\TradeSystemCrypto\2018_06_27\BfxRaw_public___07_32_41.txt"; string path = @"e:\temp993\1.txt"; string [] lines = File.ReadAllLines(path); DateTime dtStart = DateTime.Now; Console.WriteLine("started" + CUtilTime.GetDateTimeString(dtStart)); for (int i = 0; i < lines.Length; i++) { if (lines[i].Contains("== STARTED ===")) { continue; } string msg = lines[i].Remove(0, 27); bfxWebSock.ProcessData(msg); } DateTime dtEnd = DateTime.Now; double sec = (dtEnd - dtStart).TotalSeconds; Console.WriteLine("Sec=" + sec); Console.ReadKey(); }
public void Execute(List <CPosLogData> lstPoslogData) { Excel.Application excelApp = new Excel.Application(); Excel.Workbook workBook; Excel.Worksheet workSheet; workBook = excelApp.Workbooks.Add(); workSheet = (Excel.Worksheet)workBook.Worksheets.get_Item(1); var fieldNames = typeof(CPosLogData).GetProperties().ToList(); int j = 1; fieldNames.ForEach(fld => workSheet.Cells[1, j++] = fld.Name.ToString()); int i = 2; decimal _tol = 0.01m; lstPoslogData.ForEach(rec => { j = 1; typeof(CPosLogData).GetProperties().ToList().ForEach(fld => { //var el = rec.GetType().GetProperty(fld.Name); var el = CUtil.GetProperty(rec, fld.Name); workSheet.Cells[i, j++] = el; if (fld.Name == "PosGroup") { try { workSheet.Range[workSheet.Cells[i, 1], workSheet.Cells[i, 100]].Interior.Color = ColorTranslator.ToOle(_lstColor[(int)el - 1]); } catch (Exception e) { // throw e; } } if (fld.Name == "dltFee") { if (Math.Abs((decimal)el) > _tol) { _lstMarkCells.Add(new Tuple <int, int>(i, j - 1)); } } if (fld.Name == "D_Fee") { if (rec.D_Fee == 0m && rec.FeeBfx != 0m) { _lstMarkCells.Add(new Tuple <int, int>(i, j - 1)); } } if (fld.Name == "D_FeeStock") { if (rec.D_FeeStock == 0m && rec.FeeBfx != 0m) { _lstMarkCells.Add(new Tuple <int, int>(i, j - 1)); } } if (fld.Name == "DltBfxPosFee") { if (Math.Abs((decimal)el) > _tol) { _lstMarkCells.Add(new Tuple <int, int>(i, j - 1)); _lstMarkCells.Add(new Tuple <int, int>(i, j - 2)); //SumBfxFee _lstMarkCells.Add(new Tuple <int, int>(i, 15)); //P_FeeStock } } if (fld.Name == "BlnceBS") { if (Math.Abs((decimal)el) > _tol) { _lstMarkCells.Add(new Tuple <int, int>(i, j - 1)); } } } ); i++; } ); int parDtWidth = 15; int patI64Width = 13; workSheet.Range["A:A"].ColumnWidth = 5; //botID workSheet.Range["D:D"].ColumnWidth = 5; //PosDir workSheet.Range["T:T"].ColumnWidth = 5; //DealDir workSheet.Range["AD:AD"].ColumnWidth = 5; //IsFeeLateCalced workSheet.Range["AE:AE"].ColumnWidth = 5; //PosGroup workSheet.Range["E:F;R:R"].ColumnWidth = parDtWidth; //DTOpened DtClosed workSheet.Range["Q:Q;Y:Y"].ColumnWidth = patI64Width; //DealID OrderId workSheet.Range["AA:AA"].NumberFormat = "0.00"; //dltFee workSheet.Range["AG:AG"].NumberFormat = "0.00"; //DltBfxPosFee workSheet.Range["AH:AH"].NumberFormat = "0.00"; //BlnceBS //header formatting workSheet.Range["A1:AZ1"].WrapText = true; workSheet.Range["A1:AZ1"].VerticalAlignment = Excel.XlVAlign.xlVAlignTop; workSheet.Range["A1:AZ1"].Font.Size = 10; _lstMarkCells.ForEach(el => workSheet.Cells[el.Item1, el.Item2].Interior.Color = ColorTranslator.ToOle(Color.Red) ); excelApp.Visible = true; excelApp.UserControl = true; DateTime dt = DateTime.Now; string path = String.Format(@"{0}\data_{1}.xlsx", CUtil.GetDataDir(), CUtilTime.GetDateTimeString(dt)); workBook.SaveAs(path); workBook.Close(); Marshal.ReleaseComObject(workSheet); Marshal.ReleaseComObject(workBook); Marshal.ReleaseComObject(excelApp); }