Ejemplo n.º 1
0
        //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);
            }
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
    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);
                }
            }
        }
    }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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);
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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");
        }
Ejemplo n.º 10
0
        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);
            }
        }
Ejemplo n.º 11
0
        /// <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
                    });
                }
            }
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
        public override void Dispose()
        {
            _fileWriter?.Dispose();
            _fileWriter = null;

            base.Dispose();
        }
Ejemplo n.º 14
0
        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("------------------------------------------------------------------");
            }
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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();
        }
Ejemplo n.º 17
0
 public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
 {
     log4net.Config.XmlConfigurator.Configure();
     LogFileWriter.LogRequest(request);
     new TestLogic().LogRequest(request);
     return(null);
 }
Ejemplo n.º 18
0
 /// <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>));
     }
 }
Ejemplo n.º 19
0
        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);
            }
        }
Ejemplo n.º 20
0
        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
     });
 }
Ejemplo n.º 22
0
 public void CloseLogFileWriter()
 {
     if (LogFileWriter != null)
     {
         LogFileWriter.Close();
         LogFileWriter = null;
     }
 }
Ejemplo n.º 23
0
 public LogFileWriteAction(LogFileWriter file, string @group, LogFileType filetype, byte[] data,int writeNumber)
 {
     File = file;
     Group = group;
     FileType = filetype;
     Data = data;
     WriteNumber = writeNumber;
 }
Ejemplo n.º 24
0
        private ILogObserver LogWriterFactory(string filePath)
        {
            var writer = new LogFileWriter(new DefaultLogFormatter(), filePath);

            writer.Initialize();

            return(writer);
        }
Ejemplo n.º 25
0
        private void InitializeLogging()
        {
            var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), appConfig.RuntimeLogFilePath);

            logFileWriter.Initialize();
            logger.LogLevel = LogLevel.Debug;
            logger.Subscribe(logFileWriter);
        }
Ejemplo n.º 26
0
        private void InitializeLogging()
        {
            var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), logFilePath);

            logFileWriter.Initialize();
            logger.LogLevel = logLevel;
            logger.Subscribe(logFileWriter);
        }
Ejemplo n.º 27
0
        private void InitializeLogging()
        {
            var runtimeLog    = $"{appSettings.LogFilePrefix}_Runtime.log";
            var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), runtimeLog);

            logFileWriter.Initialize();
            logger.Subscribe(logFileWriter);
        }
Ejemplo n.º 28
0
 public static void Release()
 {
     if (StopwatchLog.p_logFile != null)
     {
         StopwatchLog.p_logFile.Release();
         StopwatchLog.p_logFile = null;
     }
 }
Ejemplo n.º 29
0
 public LogFileWriteAction(LogFileWriter file, string @group, LogFileType filetype, byte[] data, int writeNumber)
 {
     File        = file;
     Group       = group;
     FileType    = filetype;
     Data        = data;
     WriteNumber = writeNumber;
 }
Ejemplo n.º 30
0
 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);
    }
Ejemplo n.º 32
0
        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();
        }
Ejemplo n.º 33
0
        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);
        }
Ejemplo n.º 34
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);
        }
Ejemplo n.º 35
0
 public void LogStart(SessionStarted e)
 {
     if (_writer != null) return;
     _writer = new LogFileWriter(TemporaryFile, TemporaryDirectory);
     _dataSource.MarkDirty();
 }
Ejemplo n.º 36
0
        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;
        }