예제 #1
0
        public FucMemoryRepository()
        {
            _repo = new Dictionary<string, Fuc>();
            IEnumerable<string> fucFilenames = Directory.EnumerateFiles(@"D:\My Work\Isel\PI\i1112\trab1\FucWebApp\FucWebApp\FucDB");
            foreach(var fucFilename in fucFilenames) {
                Fuc fuc = new Fuc();
                StreamReader fucReader = new StreamReader(fucFilename);

                ParseTxtFuc(fucReader, fuc);

                _repo.Add(fuc.Acronym, fuc);
            }
        }
예제 #2
0
        protected void ParseTxtFuc(StreamReader reader, Fuc fuc)
        {
            string line = reader.ReadLine();
            int indexOfName = line.IndexOf(' ') + 1;
            fuc.Acronym = line.Substring(0, indexOfName - 1);
            fuc.Name = line.Substring(indexOfName);
            line = reader.ReadLine();
            string[] unrelateds = line.Split();
            fuc.Optional = Boolean.Parse(unrelateds[0]);
            fuc.Semester = Int32.Parse(unrelateds[1]);
            fuc.Ects = (float)Double.Parse(unrelateds[2]);
            fuc.Prereq = new List<KeyValuePair<string, string>>();
            while ((line = reader.ReadLine()) != null && line.Length != 0)
            {
                indexOfName = line.IndexOf(' ') + 1;
                string acronym = line.Substring(0, indexOfName - 2);
                string name = line.Substring(indexOfName);
                fuc.Prereq.Add(new KeyValuePair<string, string>(acronym, name));
            }
            StringBuilder builder = new StringBuilder();
            while ((line = reader.ReadLine()) != null && line.Length != 0)
                builder.Append(line);
            fuc.Objectives = builder.ToString();

            builder = new StringBuilder();
            while ((line = reader.ReadLine()) != null && line.Length != 0)
                builder.Append(line);
            fuc.Results = builder.ToString();

            builder = new StringBuilder();
            while ((line = reader.ReadLine()) != null && line.Length != 0)
                builder.Append(line);
            fuc.AvaliationResults = builder.ToString();

            builder = new StringBuilder();
            while ((line = reader.ReadLine()) != null && line.Length != 0)
                builder.Append(line);
            fuc.ResumedProgram = builder.ToString();
        }
예제 #3
0
 public static string ForPro(Fuc fuc)
 {
     ProFuc pro = fuc as ProFuc;
     return string.Format("/leic/profuc/{0}", pro.Id);
 }
예제 #4
0
 public static string ForCreate(Fuc fuc)
 {
     return string.Format("/leic/profuc/create/{0}", fuc.Acronym);
 }
예제 #5
0
 public static string For(Fuc fuc)
 {
     return string.Format("/leic/fuc/{0}", fuc.Acronym);
 }
예제 #6
0
 public static string For(Fuc f)
 {
     return string.Format("{0}/{1}", ForFuc(), f.Acr);
 }
예제 #7
0
 public void Add(Fuc fuc)
 {
     _repo.Add(fuc.Acronym, fuc);
 }