예제 #1
0
        public void ParserTest()
        {
            // Arrange
            var          file   = new FileInfo("Logs/IISLog.log");
            IISLogParser parser = new IISLogParser(file.FullName);

            // Act
            var results = parser.ParseW3CLog();

            // Assert
            Assert.IsNotNull(results);
            Assert.IsTrue(results.Count > 0);
        }
예제 #2
0
        public ActionResult GetDataIntoJSON(string baseFileName)
        {
            var reason = string.Empty;

            if (ModelState.IsValid)
            {
                try
                {
                    // if file doesn't exists.. doesn't return a file path name
                    if (baseFileName != string.Empty)
                    {
                        IISLogParser parser = null;
                        string       result = null;

                        if (baseFileName.EndsWith(".log"))
                        {
                            using (FileStream file = new FileStream(baseFileName, FileMode.Open))
                            {
                                parser = new IISLogParser(baseFileName);

                                //result = ConvertList2DataTable(parser.ParseW3CLog());
                                result = ConvertList2Json(parser.ParseW3CLog());

                                reason = Resource.FileUploadedAndParsedSuccessfully;
                                return(this.Json(new ExtractDataResult {
                                    Success = true, Message = reason, JsonData = result
                                }));
                            }
                        }
                        else
                        {
                            reason = Resource.FileFormatNotSupported;
                        }
                    }
                    else
                    {
                        reason = Resource.SelectionFile;
                    }
                }
                catch
                {
                    reason = Resource.ParsingFailed;
                }
            }

            ModelState.AddModelError("File", reason);
            return(new HttpStatusCodeResult((int)System.Net.HttpStatusCode.Unauthorized, reason));
        }