protected void Page_Load(object sender, EventArgs e) { // получение данных пользователя UserData userData = UserData.GetUserData(); // проверка входа в систему if (!userData.LoggedOn) { throw new Exception(WebPhrases.NotLoggedOn); } // перевод веб-страницы Translator.TranslatePage(this, "Scada.Web.WFrmReport"); // заполнение списка отчётов DirectoryInfo dirInfo = new DirectoryInfo(AppData.BinDir); SortedList <string, RepBuilder> repList = new SortedList <string, RepBuilder>(); if (dirInfo.Exists) { FileInfo[] fileInfoArr = dirInfo.GetFiles("Rep*.dll", SearchOption.TopDirectoryOnly); foreach (FileInfo fileInfo in fileInfoArr) { string fileName = fileInfo.Name; string fullName = fileInfo.FullName; // пропуск библиотеки базового абстрактного класса и библиотек отчётов, на которые недостаточно прав if (fileName == "RepBuilder.dll" || !userData.GetRight(fileName).ViewRight) { continue; } // загрузка библиотеки (сборки) Assembly asm = null; // библиотека try { asm = Assembly.LoadFile(fullName); } catch (Exception ex) { AppData.Log.WriteAction(string.Format(Localization.UseRussian ? "Ошибка при загрузке отчёта из библиотеки\n{0}\n{1}" : "Error loading report from the assembly\n{0}\n{1}", fullName, ex.Message), Log.ActTypes.Error); continue; } // получение типа из загруженной библиотеки Type repType = null; string typeName = "Scada.Report." + fileName.Substring(0, fileName.Length - 4); string unableMsg = string.Format(Localization.UseRussian ? "Не удалось получить тип отчёта {0} из библиотеки\n{1}" : "Unable to get the report type {0} from the assembly\n{1}", typeName, fullName); try { repType = asm.GetType(typeName); if (repType == null) { AppData.Log.WriteAction(unableMsg, Log.ActTypes.Error); continue; } } catch (Exception ex) { AppData.Log.WriteAction(unableMsg + "\n" + ex.Message, Log.ActTypes.Error); continue; } try { // создание экземпляра класса отчёта RepBuilder rep = Activator.CreateInstance(repType) as RepBuilder; // добавление отчёта в список repList.Add(rep.RepName, rep); } catch (Exception ex) { AppData.Log.WriteAction(string.Format(Localization.UseRussian ? "Ошибка при создании экземпляра класса отчёта {0} из библиотеки\n{1}\n{2}" : "Error creating report class instance {0} from the assembly\n{1}\n{2}", repType, fullName, ex.Message), Log.ActTypes.Error); } } } // вывод списка отчётов на форму if (repList.Count == 0) { lblReportList.Visible = false; lblNoReports.Visible = true; } else { for (int i = 0; i < repList.Count; i++) { RepBuilder rep = repList.Values[i]; AddReport(i + 1, rep.RepName, rep.WebFormFileName); } } }