Beispiel #1
0
        static void Main()
        {
            var generator = new SimpleGenerator();

            IList<Student> students = generator.Genereate(10);

            Console.WriteLine("Working with this set of students:\n");

            foreach (var s in students)
            {
                Console.WriteLine(s);
                Console.WriteLine("Group: {0}\n", s.GroupNumber);
            }

            var textDocParser = new TextDocumentParser();

            IList<XcelStudent> xcelStudents =
                textDocParser.Genereate(10, 10).Cast<XcelStudent>().ToList();

            foreach (var s in xcelStudents)
            {
                Console.WriteLine(s);
                Console.WriteLine("Type: {0}\n", s.StudentType);
            }
        }
Beispiel #2
0
        static void Main()
        {
            var generator = new SimpleGenerator();

            IList <Student> students = generator.Genereate(10);

            Console.WriteLine("Working with this set of students:\n");

            foreach (var s in students)
            {
                Console.WriteLine(s);
                Console.WriteLine("Group: {0}\n", s.GroupNumber);
            }

            var textDocParser = new TextDocumentParser();

            IList <XcelStudent> xcelStudents =
                textDocParser.Genereate(10, 10).Cast <XcelStudent>().ToList();

            foreach (var s in xcelStudents)
            {
                Console.WriteLine(s);
                Console.WriteLine("Type: {0}\n", s.StudentType);
            }
        }
        public IList <Transaction> Parse(string statementFilePath)
        {
            if (!CanParse(statementFilePath))
            {
                return(null);
            }

            var transactions = new List <Transaction>();

            using (var textSource = new TextSource(statementFilePath))
            {
                try
                {
                    var parsedDocument = new TextDocumentParser <StatementModel>().Parse(textSource);

                    transactions.AddRange(GetTransactions(parsedDocument));
                }
                catch (TextException)
                {
                    return(null);
                }
            }

            return(transactions);
        }
        public IList <Transaction> Parse(string statementFilePath)
        {
            if (!CanParse(statementFilePath))
            {
                return(null);
            }

            var transactions = new List <Transaction>();

            using (var textSource = new TextSource(statementFilePath))
            {
                try
                {
                    var parsedDocument = new TextDocumentParser <StatementModel>().Parse(textSource);

                    foreach (var transaction in parsedDocument.ActivityDividend)
                    {
                        if (transaction.ActivityType == "DIV")
                        {
                            transactions.Add(CreateDividendTransaction(transaction, parsedDocument.ActivityDividend));
                        }
                    }
                }
                catch (TextException)
                {
                    return(null);
                }
            }

            return(transactions);
        }
        public IList <Transaction> Parse(string statementFilePath)
        {
            if (!CanParse(statementFilePath))
            {
                return(null);
            }

            var transactions = new List <Transaction>();

            using (var textSource = new TextSource(statementFilePath))
            {
                try
                {
                    var parsedDocument = new TextDocumentParser <StatementModel>().Parse(textSource);

                    transactions.AddRange(parsedDocument.ActivityOther.Select(i => CreateOtherTransaction(i, parsedDocument.Year)));
                    transactions.AddRange(parsedDocument.ActivityDividend.Select(i => CreateDividendTransaction(parsedDocument.ActivityTaxes, i, parsedDocument.Year)));
                    transactions.AddRange(parsedDocument.ESPP.Select(i => CreateESPPTransaction(parsedDocument.ActivityBuy, i)));
                }
                catch (TextException)
                {
                    return(null);
                }
            }

            return(transactions);
        }
        static void Main()
        {
            helper.ConsoleMio.Setup();
            helper.ConsoleMio.PrintHeading("LINQ to Excel ");

            var studentsExtractor = new TextDocumentParser();

            IList <XcelStudent> students =
                studentsExtractor.Genereate(1000).Cast <XcelStudent>().ToList();

            var sheet = new Worksheet("Online Students");

            string[] sheetHeader = studentsExtractor.HeaderLine;

            for (int i = 0; i < sheetHeader.Length; i++)
            {
                sheet.Cells[0, i] = new Cell(sheetHeader[i]);
            }

            // Add the result filed in the end
            sheet.Cells[0, sheetHeader.Length] = new Cell("Result");

            helper.ConsoleMio.PrintColorText("Proccessing information...\n\n", ConsoleColor.DarkCyan);
            var onlineStudents = students
                                 .Where(student => student.StudentType == StudentType.Online)
                                 .OrderByDescending(student => student.CalculateResult())
                                 .ToArray();

            for (int i = 0; i < onlineStudents.Length; i++)
            {
                XcelStudent student = onlineStudents[i];
                AddStudentDataToSheet(sheet, i + 1, student);
            }

            var workbook = new Workbook();

            workbook.Worksheets.Add(sheet);

            helper.ConsoleMio.PrintColorText(
                "Query Completed\n", ConsoleColor.Green);

            string saveLocation = helper.SelectSaveLocation("Xcel Files|*.xls");

            workbook.Save(saveLocation);

            helper.ConsoleMio.PrintColorText("Done", ConsoleColor.Green);

            helper.ConsoleMio.Restart(Main);
        }
        static void Main()
        {
            helper.ConsoleMio.Setup();
            helper.ConsoleMio.PrintHeading("LINQ to Excel ");

            var studentsExtractor = new TextDocumentParser();

            IList<XcelStudent> students =
                studentsExtractor.Genereate(1000).Cast<XcelStudent>().ToList();

            var sheet = new Worksheet("Online Students");
            string[] sheetHeader = studentsExtractor.HeaderLine;

            for (int i = 0; i < sheetHeader.Length; i++)
            {
                sheet.Cells[0, i] = new Cell(sheetHeader[i]);
            }

            // Add the result filed in the end
            sheet.Cells[0, sheetHeader.Length] = new Cell("Result");

            helper.ConsoleMio.PrintColorText("Proccessing information...\n\n", ConsoleColor.DarkCyan);
            var onlineStudents = students
                .Where(student => student.StudentType == StudentType.Online)
                .OrderByDescending(student => student.CalculateResult())
                .ToArray();

            for (int i = 0; i < onlineStudents.Length; i++)
            {
                XcelStudent student = onlineStudents[i];
                AddStudentDataToSheet(sheet, i + 1, student);
            }

            var workbook = new Workbook();
            workbook.Worksheets.Add(sheet);

            helper.ConsoleMio.PrintColorText(
                "Query Completed\n", ConsoleColor.Green);

            string saveLocation = helper.SelectSaveLocation("Xcel Files|*.xls");
            workbook.Save(saveLocation);

            helper.ConsoleMio.PrintColorText("Done", ConsoleColor.Green);

            helper.ConsoleMio.Restart(Main);
        }