Esempio n. 1
0
 /// <summary>
 /// загружает сессию
 /// </summary>
 /// <param name="path">путь к папке</param>
 public void LoadSession(string path)
 {
     if (Directory.Exists(path))
     {
         if (path.Contains("\\Resources\\Demo"))
         {
             _demo = true;
         }
         _loading = true;
         _sessionPath = path + "\\";
         var files = new DirectoryInfo(_sessionPath).GetFiles();
         foreach (var file in files)
         {
             var extension = file.FullName.Substring(file.FullName.Length - 7);
             if (extension == "plm.xml" || extension == "pli.xml")
             {
                 _planPath = file.FullName;
                 _parser = new XParser(_planPath);
                 FormDataInitilizer = new Initilizer(_parser);
                 continue;
             }
             var typeName = file.Name.Substring(0, file.Name.Length - 4);
             var type = Type.GetType("DataLibrary." + typeName + ",DataLibrary");
             if (type != null)
             {
                 try
                 {
                     var ob = Activator.CreateInstance(type);
                     ob = SerializeHelper.Deserialize(ob, file.FullName);
                     SessionObjects.SetProperty(type, ob);
                 }
                 catch
                 {
                 }
             }
         }
         _loading = false;
         if (_planPath == String.Empty)
         {
             throw new IOException("В папке с сеансом нет файла с планом. Обновите учебный план." + path);
         }
         UpdateObjects();
         SearchEngine = new Searcher(_sessionPath);
         _readyToWork = true;
         _newSession = false;
     }
     else
     {
         ClearSession();
         throw new IOException("Невозможно найти путь: " + path);
     }
 }
Esempio n. 2
0
 public Initilizer(XParser parser)
 {
     _parser = parser;
 }
Esempio n. 3
0
 /// <summary>
 /// создает новую сессию
 /// </summary>
 public void CreateSession(string planFileName)
 {
     _sessionPath = _startDir + "\\";
     if (!Directory.Exists(_sessionPath))
     {
         Directory.CreateDirectory(_sessionPath);
         _sessionPath += "\\S1";
     }
     else
     {
         var childDirs = new DirectoryInfo(_sessionPath).GetDirectories();
         _sessionPath += "S" + (childDirs.Length + 1).ToString();
     }
     _sessionPath = Helper.CreateDir(_sessionPath);
     _sessionPath += "\\";
     _planPath = _sessionPath + new FileInfo(planFileName).Name;
     File.Copy(planFileName, _planPath);
     _parser = new XParser(_planPath);
     FormDataInitilizer = new Initilizer(_parser);
     _newSession = true;
     #region titlePage
     SessionObjects.TitlePage.University = FormDataInitilizer.GetUniversityName();
     SessionObjects.TitlePage.Qualification = FormDataInitilizer.GetQualification();
     SessionObjects.TitlePage.FormOfTraining = FormDataInitilizer.GetFormOfTraining();
     #endregion
     SearchEngine = new Searcher(_sessionPath);
     ValidatePlan();
     _readyToWork = true;
 }