Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Log4Net.InitLogger();
            SetLang(System.Globalization.CultureInfo.CurrentCulture.Name);
            //Console.WriteLine("WCF服务启动中...");
            Log4Net.Info(typeof(Program), "WCF服务启动中...", true);

            List <ServiceInfo> serviceInfoList = new List <ServiceInfo>();

            serviceInfoList = ServiceManager.Instance.ServiceProvider();
            ServiceManager.Instance.OpenService(serviceInfoList);
            Console.WriteLine("按Q键退出程序...");
            while (Console.ReadLine() == "C")
            {
                ServiceManager.Instance.CloseService(serviceInfoList);
            }
            while (Console.ReadLine() != "Q")
            {
                continue;
            }
        }
Exemplo n.º 2
0
        public void Process(string[] args)
        {
            var logger = Log4Net.Log;

            Log4Net.InitLogger();

            string   inputPath = string.Empty, outputPath = string.Empty;
            FileMode mode = FileMode.Json;

            Parser.Default.ParseArguments <Options>(args)
            .WithParsed(o =>
            {
                inputPath  = o.InputFile;
                outputPath = o.OutputFile;
                mode       = o.Mode;
            });

            var students = new List <Student>();

            try
            {
                students = (List <Student>)Services.CsvReader.Read(inputPath);
            }
            catch (FormatException e)
            {
                logger.Error(e.Message);
                return;
            }
            catch (ArgumentException e)
            {
                logger.Error(e.Message);
                return;
            }
            catch (ReaderException e)
            {
                logger.Error(e.Message);
                return;
            }
            catch (TypeConverterException e)
            {
                logger.Error(e.Message);
                return;
            }
            catch (System.IO.FileNotFoundException e)
            {
                logger.Error(e.Message);
                return;
            }

            var finalReport = new FinalReport
            {
                StudentResults = students.GetStudentsResult(),
                ExamResults    = students.GetExamResults(),
                Average        = students.GetGroupAverage(),
            };

            switch (mode)
            {
            case FileMode.Json:
                var jsonWriter = new JsonWriter();
                jsonWriter.Write(outputPath, finalReport);
                break;

            case FileMode.Excel:
                var excelWriter = new ExcelWriter();
                excelWriter.Write(outputPath, finalReport);
                break;

            default:
                break;
            }
        }