//public bool ValidateCardLoaded(string cardNumber) //{ // //check if the card has been loaded into the DB // try // { // using (SqlConnection con = dbObject.SQLConnection) // { // string sql = // "OPEN SYMMETRIC KEY Indigo_Symmetric_Key " + // "DECRYPTION BY CERTIFICATE Indigo_Certificate; " + // "SELECT card_number FROM load_card WHERE " + // "DECRYPTBYKEY(card_number) = '" + cardNumber + "' " + // "CLOSE SYMMETRIC KEY Indigo_Symmetric_Key;"; // var command = new SqlCommand(sql, con); // SqlDataReader dataReader = command.ExecuteReader(); // if (dataReader.HasRows) // return true; // else // return false; // } // } // catch (Exception ex) // { // LogFileWriter.WriteFileLoaderError(ToString(), ex); // return false; // } //} public bool CheckPinMailerLoaded(string cardNumber, string encryptedPinBlock) { //check if the PIN MAILER has been loaded into the DB try { using (SqlConnection con = dbObject.SQLConnection) { string sql = " SELECT * FROM pin_mailer WHERE card_number ='" + cardNumber + "' AND encrypted_pin = '" + encryptedPinBlock + "'"; var command = new SqlCommand(sql, con); SqlDataReader dataReader = command.ExecuteReader(); if (dataReader.HasRows) { return(true); } else { return(false); } } } catch (Exception ex) { LogFileWriter.WriteFileLoaderError(ToString(), ex); return(false); } }
static void Main() { LogFileWriter log = new LogFileWriter(); try { if (DatabaseConnection.OpenConnections() == false) { UIUtil.ShowError("Cannot open database connection.", "ImportData - Error", true); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } catch (Exception ex) { log.WriteLog("Unexpected error happened in main: " + ex.Message, ex.StackTrace); UIUtil.ShowError("Unexpected error happened: " + ex.Message, "ImportData - Error", true); } finally { DatabaseConnection.CloseConnections(); } }
public void WriteFile(System.Object param) { LogFileWriter lfw = (LogFileWriter)param; while (lfw.isWorking) { lock (logsLock) { if (logs == null || logs.Count == 0) { Monitor.Wait(logsLock); } wrLogs = logs; logs = new Queue <Log>(); } while (wrLogs.Count != 0) { Log log = wrLogs.Dequeue(); if (log != null) { WriteFile(log); } } } }
private void RegisterNonExistanceBranch(string record, string brachCode, issuer config) { try { //if (!Directory.Exists(config.cards_file_location + "\\missingBranches")) //{ // Directory.CreateDirectory(config.cards_file_location + "\\missingBranches"); //} StreamWriter sr = new StreamWriter(//config.cards_file_location + "\\missingBranches\\" + config.issuer_code + "_" + brachCode + ".OUT", true); sr.WriteLine(record); sr.Flush(); sr.Close(); LogFileWriter.WriteFileLoaderError( config.issuer_code + ": " + fullFileName + " contains records of a non existant branch", new Exception("INVALID ISSUER BRANCH")); fileLoadComments += " | file contains data for a non existant branch in this issuer, please ensure branches are created prior loading"; fileStatus = FileStatus.PARTIAL_LOAD; } catch (Exception ex) { LogFileWriter.WriteFileLoaderError(ToString(), ex); } }
private FileInfo[] GetFilesToLoad(issuer config, DirectoryInfo dirInfo) { try { FileInfo[] filesToLoad = FilesToImport(dirInfo); if (filesToLoad.Count() == 0) { //build app log comment applogcomment += "No files to load"; return(null); } //build app log comment applogcomment += " Total=" + filesToLoad.Count(); return(filesToLoad); } catch (Exception ex) { //build app log comment applogcomment += "Invalid directory: " + dirInfo.FullName; //write to error log LogFileWriter.WriteFileLoaderError(config.issuer_code + ": Cannot find import directory: " + dirInfo.FullName + ToString(), ex); return(null); } }
private void SaveChatLogs() { try { LogFileWriter writer = new LogFileWriter(); Logger.Info(Language.Instance.GetMessageFromKey("SAVE_CHATLOGS")); List <ChatLogEntry> tmp = ChatLogs.GetAllItems(); ChatLogs.Clear(); DateTime current = DateTime.UtcNow; string path = "chatlogs"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = Path.Combine(path, current.Year.ToString()); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = Path.Combine(path, current.Month.ToString()); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = Path.Combine(path, current.Day.ToString()); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } writer.WriteLogFile(Path.Combine(path, $"{(current.Hour < 10 ? $"0{current.Hour}" : $"{current.Hour}")}.{(current.Minute < 10 ? $"0{current.Minute}" : $"{current.Minute}")}.onc"), tmp);
public void LogStop(SessionStopped e) { if (_writer == null) { return; } if (Annotater == null) { _closeWriter = new Task((x) => ((LogFileWriter)x).Save(), _writer); _closeWriter.Start(); } else { if (Annotater.QualifiesForStorage(this)) { _closeWriter = new Task((x) => { ((LogFileWriter)x).Save(); Annotater.Store(this, ((LogFileWriter)x)); }, _writer); _closeWriter.Start(); } else { _writer.Clear(); } } _writer = null; }
public void Data() { var counter = 0; var file = new LogFileWriter("test3.zip", "LogFileWriterTestsData"); var source = new MemoryPool("test", MemoryAddress.StaticAbsolute, 0x123456, 0, 0x1234); source.Add(new MemoryFieldFunc <int>("testInt", (pool) => counter++)); // these are always logged source.Add(new MemoryFieldFunc <string>("test", (pool) => "test")); file.Subscribe(source); // Fill up a data file for (int i = 0; i < 1441792; i++) // 38.5MiB { file.Update(i); // +28 bytes } // We should have logged 2 data files by now. Assert.True(File.Exists("LogFileWriterTestsData/test/Data.bin")); file.Save(); ZipStorer z = ZipStorer.Open("test3.zip", FileAccess.Read); var files = z.ReadCentralDir(); Assert.AreEqual(3, files.Count); Assert.True(files.Any(x => x.FilenameInZip == "test/Data.bin")); Assert.True(files.Where(x => x.FilenameInZip == "test/Data.bin").FirstOrDefault().FileSize == 1441792 * ((2 + 4 + 4 + 2) + (2 + 4 + 4 + 4 + 2))); Assert.True(files.Any(x => x.FilenameInZip == "test/Structure.xml")); Assert.True(files.Any(x => x.FilenameInZip == "test/Time.bin")); Assert.True(files.Where(x => x.FilenameInZip == "test/Time.bin").FirstOrDefault().FileSize == 1441792 * 8); }
private void btnAppend_Click(object sender, EventArgs e) { PopulateSingleton(); Logger logger = new Logger("vjhveruio huiruierg", @"C:\OxigenData\SettingsData\OxigenDebug.txt"); try { LogFileWriter.WriteLogs(@"C:\OxigenData\SettingsData\ss_ad_c_1.dat", @"C:\OxigenData\SettingsData\ss_ad_c_2.dat", @"C:\OxigenData\SettingsData\ss_ad_s_1.dat", @"C:\OxigenData\SettingsData\ss_ad_s_2.dat", @"C:\OxigenData\SettingsData\ss_co_c_1.dat", @"C:\OxigenData\SettingsData\ss_co_c_2.dat", @"C:\OxigenData\SettingsData\ss_co_s_1.dat", @"C:\OxigenData\SettingsData\ss_co_s_2.dat", @"C:\OxigenData\SettingsData\ss_usg_1.dat", @"C:\OxigenData\SettingsData\ss_usg_2.dat", "machineGUIDGoesHere", "userGUIDGoesHere", 123, "password", true, false, logger); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return; } MessageBox.Show("Logs Appended and Encrypted"); }
public static Equation ChooseEquationType(string type, LogFileWriter logWriter) { Equation equation; double x2Coefficient, xCoefficient, freeCoefficient; switch (type) { case "L": xCoefficient = DoubleNumberInputter.ReadNumberFromConsole(logWriter); DoubleNumberInputter.ReadNumberNotZero(ref xCoefficient, logWriter); freeCoefficient = DoubleNumberInputter.ReadNumberFromConsole(logWriter); equation = new LinearEquation(xCoefficient, freeCoefficient); return(equation); case "Q": x2Coefficient = DoubleNumberInputter.ReadNumberFromConsole(logWriter); DoubleNumberInputter.ReadNumberNotZero(ref x2Coefficient, logWriter); xCoefficient = DoubleNumberInputter.ReadNumberFromConsole(logWriter); freeCoefficient = DoubleNumberInputter.ReadNumberFromConsole(logWriter); equation = new QuadraticEquation(x2Coefficient, xCoefficient, freeCoefficient); return(equation); default: return(null); } }
/// <summary> /// Extract data from PDF and write out data to a Csv file /// </summary> /// <param name="pdfFilePath">Fully qualified path of the PDF file</param> /// <param name="converterFileName"></param> protected static ParseOutput ParsePdf(string pdfFilePath, string converterFileName) { try { LogFileWriter.WriteErrorLine("[" + converterFileName + "] Processing " + FileHelper.GetFileNameFromPath(pdfFilePath) + ".pdf (" + DateTime.Now.ToString("HH:mm:ss") + ")"); return(TryParse(pdfFilePath, converterFileName)); } catch { try { Thread.Sleep(10000); return(TryParse(pdfFilePath, converterFileName)); } catch (Exception e) { var errorMessage = new StringBuilder(); errorMessage.AppendFormat("********************** Error Parsing PDF: {0} [{1}]", FileHelper.GetFileNameFromPath(pdfFilePath) + ".pdf", e.Message); LogFileWriter.WriteErrorLine(pdfFilePath); LogFileWriter.WriteErrorLine(errorMessage.ToString()); LogFileWriter.WriteErrorLine(e.StackTrace); return(new ParseOutput { IsMiscDeposit = false, PdfFileName = pdfFilePath, ConverterName = converterFileName, CSVFileName = string.Empty, CSVRowCount = 0 }); } } }
public void Store(TelemetryLogger logger, LogFileWriter writer) { var suggestedPath = GetPath(logger); // Any directories that do not exist yet? var directoryParts = suggestedPath.Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries); var cumalativeParts = new string[directoryParts.Length]; var i = 0; foreach (var part in directoryParts) { if (i + 1 == directoryParts.Length) { break; } if (i > 0) { cumalativeParts[i] = cumalativeParts[i - 1] + "/" + part; } else { cumalativeParts[i] = part; } if (Directory.Exists(cumalativeParts[i]) == false) { Directory.CreateDirectory(cumalativeParts[i]); } i++; } // TODO: get configuration file Telemetry directory File.Move("./tmp.zip", suggestedPath); }
public override void Dispose() { _fileWriter?.Dispose(); _fileWriter = null; base.Dispose(); }
private static void AsyncProcessPdf(object stateInfo) { var threadParameters = (ThreadData)stateInfo; try { var durationStopWatch = new Stopwatch(); durationStopWatch.Start(); var startTime = DateTime.Now; var statementProcessor = Factory.CreateInstance <IStatementProcessor>(Settings.ClassSpec); var parseOutput = statementProcessor.ProcessPdf(threadParameters.FullyQualifiedName); durationStopWatch.Stop(); parseOutput.StartTime = startTime; parseOutput.EndTime = DateTime.Now; parseOutput.Duration = durationStopWatch.ElapsedMilliseconds / 1000.0M; if (parseOutput.DocumentWasStored) { LogFileWriter.WriteParseOutput(parseOutput); } } catch (Exception exception) { var errorMessage = "Error processing " + threadParameters.FileName; LogFileWriter.WriteErrorLine("------------------------------------------------------------------"); LogFileWriter.WriteErrorLine(errorMessage); LogFileWriter.WriteErrorLine(exception.Message); LogFileWriter.WriteErrorLine("------------------------------------------------------------------"); } }
public bool CreateArticle(string articleNo, string name, int priceCalcMethodsNo, int postingTemplate, int stockProfileNo) { _articleComponent.bcInitData(); _articleComponent.bcSetInitialValues(); _articleComponent.bcSetValueFromStr((int)Article_Properties.ART_ArticleNo, articleNo); _articleComponent.bcUpdateStr((int)Article_Properties.ART_Name, name); // Konteringsmall _articleComponent.bcUpdateInt((int)Article_Properties.ART_PostingTemplateNo, postingTemplate); // Prisprofil _articleComponent.bcUpdateInt((int)Article_Properties.ART_PriceCalcMethodsNo, priceCalcMethodsNo); // Lagerprofil _articleComponent.bcUpdateInt((int)Article_Properties.ART_StockProfileNo, stockProfileNo); var errCode = _articleComponent.bcAddNew(); if (errCode != 0) { _articleComponent.bcCancelRecord(); LogFileWriter.WriteLine(string.Format("Attempt to create article '{0} - {1}' failed. Code {2} - {3}", articleNo, name, errCode, _articleComponent.bcGetMessageText(errCode))); return(false); } return(true); }
static void Main(string[] args) { const string LogFile = "log.txt"; LogFileWriter logWriter = new LogFileWriter(LogFile); if (logWriter.LogFile == null)//throw exception { Console.WriteLine("LogFile doesn't exist or is readOnly!"); } Console.WriteLine("Choose type of equation you want to solve: 'L' - linear, 'Q' - quadratic\n" + "or any other key to exit and press 'Enter':"); Equation equation = ChooseEquationType(Console.ReadLine().ToUpper(), logWriter); if (equation != null) { string result = equation.GetEquationAndSolutionRecord(); Console.WriteLine(result); logWriter.WriteEquationToLog(result); } string fileNameWithMatrix = ConfigurationManager.AppSettings["fileNameWithMatrix"]; MatrixReader matrixReader = new MatrixReader(fileNameWithMatrix); double[,] matrix1 = matrixReader.GetMatrix(); double[,] matrix2 = matrixReader.GetMatrix(); Console.WriteLine(MatrixCalculator.GetMultiplicationStringResult(matrix1, matrix2)); Console.ReadKey(); }
public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext) { log4net.Config.XmlConfigurator.Configure(); LogFileWriter.LogRequest(request); new TestLogic().LogRequest(request); return(null); }
/// <summary> /// Load Munities and Amount /// </summary> public ObservableCollection <ModelBillConfig> LoadBillConfig() { try { string billXmlPath = Path.Combine(GetTempFolder(CvVariables.SOFTWARE_NAME), CvVariables.MUNITIES_FILE); if (File.Exists(billXmlPath)) { XElement billConfigXml = XElement.Load(billXmlPath); return(new ObservableCollection <ModelBillConfig>(from bilinginfo in billConfigXml.Elements("Rate") select new ModelBillConfig { Minutes = bilinginfo.Element("Minutes").Value, Amount = bilinginfo.Element("Bill").Value })); } else { return(new ObservableCollection <ModelBillConfig>()); } } catch (Exception ErrorException) { LogFileWriter.ErrorToLog("Loading Bill Configuration File", ErrorException); return(default(ObservableCollection <ModelBillConfig>)); } }
internal void InsertPinBatchRecord(string batchReference, string loadedDT, int mailerCount, int issuerID, string branchCode) { //writes a load batch record to the load_batch table Console.WriteLine("Writing batch to DB"); var sqlStatement = new StringBuilder(""); sqlStatement.Append("INSERT INTO pin_batch VALUES ("); sqlStatement.Append("'" + batchReference + "', "); sqlStatement.Append("'" + loadedDT + "', "); sqlStatement.Append("'" + mailerCount + "', "); sqlStatement.Append("'" + issuerID + "', "); sqlStatement.Append("'', "); //manager comment sqlStatement.Append("'LOADED',"); sqlStatement.Append("'', "); //operator comment sqlStatement.Append("'" + branchCode + "')"); try { using (SqlConnection con = dbObject.SQLConnection) { string sql = sqlStatement.ToString(); var command = new SqlCommand(sql, con); command.ExecuteNonQuery(); Console.WriteLine("Batch written to DB OK"); } } catch (Exception ex) { LogFileWriter.WriteFileLoaderError(ToString(), ex); } }
private static void WriteLogs(bool bFinalWrite) { if (_bErrorOnStartup) { _logger.WriteTimestampedMessage("there was an error on startup. Cannot write logs. Exiting."); return; } // method may have been fired by the _logTimer. In this case, if method is also fired // as application exists and the timer call hasn't yet finished, wait. // the probability of two timer calls come as close together as for the first call not to have // finished is practically zero as the _logTimer interval is long enough. while (_bAlreadyWritingLogs) { ; } _bAlreadyWritingLogs = true; // play time in this session int playTime = (int)Math.Round((DateTime.Now.Subtract(_startDateTime)).TotalSeconds, 0); // write log files try { LogFileWriter.WriteLogs(_advertClickLogsPath1, _advertClickLogsPath2, _advertImpressionLogsPath1, _advertImpressionLogsPath2, _contentClickLogsPath1, _contentClickLogsPath2, _contentImpressionLogsPath1, _contentImpressionLogsPath2, _usageCountLogsPath1, _usageCountLogsPath2, _user.MachineGUID, // closed networks: this may not be populated until CE or LE run. That's fine as no logs will be written if CE has not run to download content first. _user.UserGUID, playTime, _password, bFinalWrite, _bPreviewMode, _logger); _logger.WriteTimestampedMessage("successfully wrote logs."); } catch (Exception ex) { _logger.WriteError(ex); } if (bFinalWrite) { LogEntriesRawSingleton.Reset(); _logger.WriteTimestampedMessage("successfully cleared the lgo object."); } _bAlreadyWritingLogs = false; }
/// <inheritdoc /> public ParseOutput ProcessPdf(string pdfFileName) { LogFileWriter.WriteLine($"Processed file {pdfFileName}."); return(new ParseOutput { DocumentWasStored = true }); }
public void CloseLogFileWriter() { if (LogFileWriter != null) { LogFileWriter.Close(); LogFileWriter = null; } }
public LogFileWriteAction(LogFileWriter file, string @group, LogFileType filetype, byte[] data,int writeNumber) { File = file; Group = group; FileType = filetype; Data = data; WriteNumber = writeNumber; }
private ILogObserver LogWriterFactory(string filePath) { var writer = new LogFileWriter(new DefaultLogFormatter(), filePath); writer.Initialize(); return(writer); }
private void InitializeLogging() { var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), appConfig.RuntimeLogFilePath); logFileWriter.Initialize(); logger.LogLevel = LogLevel.Debug; logger.Subscribe(logFileWriter); }
private void InitializeLogging() { var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), logFilePath); logFileWriter.Initialize(); logger.LogLevel = logLevel; logger.Subscribe(logFileWriter); }
private void InitializeLogging() { var runtimeLog = $"{appSettings.LogFilePrefix}_Runtime.log"; var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), runtimeLog); logFileWriter.Initialize(); logger.Subscribe(logFileWriter); }
public static void Release() { if (StopwatchLog.p_logFile != null) { StopwatchLog.p_logFile.Release(); StopwatchLog.p_logFile = null; } }
public LogFileWriteAction(LogFileWriter file, string @group, LogFileType filetype, byte[] data, int writeNumber) { File = file; Group = group; FileType = filetype; Data = data; WriteNumber = writeNumber; }
public void LogStart(SessionStarted e) { if (_writer != null) { return; } _writer = new LogFileWriter(TemporaryFile, TemporaryDirectory); _dataSource.MarkDirty(); }
public void Begin() { string text = Path.Combine(Application.get_persistentDataPath(), "MemoryInfo"); string text2 = string.Format("{0}.txt", DateTime.get_Now().ToString("yyyyMMdd_HHmmss")); string file = Path.Combine(text, text2); this.LogFile = new LogFileWriter(); this.LogFile.Init(file, 2); }
public LogGroup(LogFileWriter writer, string name, IDataNode dataSource) { FileWriter = writer; Name = name; DataSource = dataSource; Subscribed = true; TimeStream = new LogGroupStream(this, LogFileType.Time, 1024 * 1024); DataStream = new LogGroupStream(this, LogFileType.Data, 1024 * 1024); _fields = dataSource.GetDataFields().Select(x => new LogField(this, x, GetNewFieldId())).ToList(); }
public void StoreLogFile() { var dummyDataSource = new MockDataSource(); var archive = new TelemetryArchive(); var loggerFromZero = new TelemetryLogger("test", new TelemetryLoggerConfiguration(true, true, true, true)); loggerFromZero.SetDatasource(dummyDataSource); loggerFromZero.SetAnnotater(archive); var logWriter = new LogFileWriter("test.zip","TelemetryArchiveTestsStoreLogFile"); GlobalEvents.Fire(new SessionStarted(), true); loggerFromZero.Update(0); loggerFromZero.Update(10000); loggerFromZero.Update(20000); GlobalEvents.Fire(new SessionStopped(), true); Thread.Sleep(5000); }
public void Store(TelemetryLogger logger, LogFileWriter writer) { var suggestedPath = GetPath(logger); // Any directories that do not exist yet? var directoryParts = suggestedPath.Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries); var cumalativeParts = new string[directoryParts.Length]; var i = 0; foreach(var part in directoryParts) { if (i + 1 == directoryParts.Length) break; if (i > 0) cumalativeParts[i] = cumalativeParts[i - 1] + "/" + part; else cumalativeParts[i] = part; if (Directory.Exists(cumalativeParts[i]) == false) Directory.CreateDirectory(cumalativeParts[i]); i++; } // TODO: get configuration file Telemetry directory File.Move("./tmp.zip", suggestedPath); }
public void LogStart(SessionStarted e) { if (_writer != null) return; _writer = new LogFileWriter(TemporaryFile, TemporaryDirectory); _dataSource.MarkDirty(); }
public void LogStop(SessionStopped e) { if (_writer == null) return; if (Annotater == null) { _closeWriter = new Task((x) => ((LogFileWriter)x).Save(), _writer); _closeWriter.Start(); } else { if (Annotater.QualifiesForStorage(this)) { _closeWriter = new Task((x) => { ((LogFileWriter) x).Save(); Annotater.Store(this, ((LogFileWriter) x)); }, _writer); _closeWriter.Start(); } else { _writer.Clear(); } } _writer = null; }