public void InitDashboardOrders() { foreach (var dOrder in DefaultDashboards) { dOrder.Dashboard = Dashboards.FirstOrDefault(i => i.GUID == dOrder.GUID); dOrder.SecurityGroup = this; } DefaultDashboards.RemoveAll(i => Dashboards == null); }
void loadDashboard(string path, string folderPath, string folderName, bool editable, bool isPersonal) { try { var dashboard = Dashboards.FirstOrDefault(i => i.Path == path); if (dashboard == null || dashboard.LastModification != File.GetLastWriteTime(path)) { if (dashboard != null) { Dashboards.Remove(dashboard); } dashboard = Dashboard.LoadFromFile(path); Dashboards.Add(dashboard); } dashboard.IsPersonal = isPersonal; dashboard.Editable = editable; dashboard.Folder = folderPath; dashboard.DisplayName = Security.Repository.TranslateDashboardName(path.Replace(Security.Repository.DashboardPublicFolder, ""), dashboard.Name); var repositoryPath = path.Replace(Security.Repository.DashboardPublicFolder, ""); if (dashboard.IsPersonal) { dashboard.FullName = string.Format("{0} ({1})", dashboard.DisplayName, Security.Repository.TranslateWeb("Personal")); } else if (!string.IsNullOrEmpty(folderName)) { dashboard.FullName = string.Format("{0} ({1})", dashboard.DisplayName, Security.Repository.TranslateDashboardFolder(Path.GetDirectoryName(repositoryPath), folderName)); } else { dashboard.FullName = dashboard.DisplayName; } dashboard.ReinitGroupOrders(); //Init items and translate labels foreach (var item in dashboard.Items) { var widget = DashboardWidgetsPool.Widgets.ContainsKey(item.WidgetGUID) ? DashboardWidgetsPool.Widgets[item.WidgetGUID] : null; if (widget == null) { continue; } if (!string.IsNullOrEmpty(item.Name) && item.Name != widget.Name) { item.DisplayName = Security.Repository.TranslateDashboardItemName(repositoryPath, item.Name); } else { var instance = widget.ReportPath.Replace(Security.Repository.ReportsFolder, Path.DirectorySeparatorChar.ToString()); item.DisplayName = Security.Repository.TranslateWidgetName(instance, widget.Name); } item.SetWidget(widget); if (!string.IsNullOrEmpty(item.GroupName)) { item.DisplayGroupName = Security.Repository.TranslateDashboardItemGroupName(repositoryPath, item.GroupName); } } //Remove lost widgets... dashboard.Items.RemoveAll(i => i.Widget == null); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }