コード例 #1
0
        public void Export(Contest contest, Clazz clazz, Task task)
        {
            string template = Path.Combine(Properties.Settings.Default.ExportTemplateDirectory, filename + ".tpl");
            string content = File.ReadAllText(template);
            //task.GetClazz();

            content = fillTemplate(content, contest, clazz, task);

            string file = Path.Combine(Properties.Settings.Default.ExportWorkDirectory, task.Date + "_" + clazz.Type + "_" + filename);

            if (Properties.Settings.Default.ExportDebug)
                Console.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss") + " Export] Exporting file " + file);

            File.WriteAllText(file, content);
        }
コード例 #2
0
        public void Export(Contest contest)
        {
            foreach (Clazz clazz in contest.GetClazzes())
            {
                foreach (Task task in clazz.GetTasks())
                {

                    if (!(new DateUtils()).Matches(Properties.Settings.Default.ExportFilter, task.Date))
                        continue;

                    foreach (Template template in templates)
                    {
                        template.Export(contest, clazz, task);
                    }
                }
            }
        }
コード例 #3
0
        private string fillTemplate(string template, Contest contest, Clazz clazz, Task task)
        {
            template = Regex.Replace(template, "<Contest:Name.*?/>", contest.Name);
            template = Regex.Replace(template, "<Contest:StartDate.*?/>", contest.StartDate);
            template = Regex.Replace(template, "<Contest:EndDate.*?/>", contest.EndDate);

            template = Regex.Replace(template, "<Task:Class.*?/>", clazz.Name);
            template = Regex.Replace(template, "<Task:Date.*?/>", task.Date);
            template = Regex.Replace(template, "<Task:Name.*?/>", task.Name);

            template = Regex.Replace(template, "<General:DateTime.*?/>", DateTime.Now.ToString("yyyy-MM-dd HH:mm"));

            template = fillImages(template, task);
            template = fillResults(template, task);
            template = fillPoints(template, task);

            return template;
        }