public ActionResult SWILogin(string user, string password) { WriteDebug("SWILogin"); try { if (WebUser == null || !WebUser.IsAuthenticated || (!string.IsNullOrEmpty(user) && WebUser.WebUserName != user)) { CreateRepository(); CreateWebUser(); WebUser.WebPrincipal = User; WebUser.WebUserName = user; WebUser.WebPassword = password; Authenticate(); if (!WebUser.IsAuthenticated) { throw new Exception(string.IsNullOrEmpty(WebUser.Error) ? Translate("Invalid user name or password") : WebUser.Error); } } //Set culture from cookie if (!string.IsNullOrEmpty(WebUser.Profile.Culture)) { Repository.SetCultureInfo(WebUser.Profile.Culture); } //Set default view string view = WebUser.Profile.View; //Check rights if (WebUser.ViewType == Seal.Model.ViewType.Reports && view == "dashboards") { view = "reports"; } else if (WebUser.ViewType == Seal.Model.ViewType.Dashboards && view == "reports") { view = "dashboards"; } //Refresh widgets DashboardWidgetsPool.ForceReload(); DashboardExecutions.Clear(); return(Json(new SWIUserProfile() { name = WebUser.Name, group = WebUser.SecurityGroupsDisplay, culture = Repository.CultureInfo.EnglishName, folder = GetCookie(SealLastFolderCookieName), dashboard = GetCookie(SealLastDashboardCookieName), viewtype = WebUser.ViewType, lastview = view, dashboardFolders = WebUser.DashboardFolders.ToArray(), manageDashboards = WebUser.ManageDashboards })); } catch (Exception ex) { return(HandleSWIException(ex)); } }
public void ViewWidgetsList(ExecutionLogInterface log) { Repository repository = Repository.Instance.CreateFast(); StringBuilder translations = new StringBuilder(); try { DashboardWidgetsPool.ForceReload(); log.Log("Building the list of Published Widgets in the repository...\r\n"); foreach (var path in (from w in DashboardWidgetsPool.Widgets.Values select w.ReportPath).Distinct().OrderBy(i => i)) { if (log.IsJobCancelled()) { return; } Report report = Report.LoadFromFile(repository.ReportsFolder + path, repository, false); StringBuilder summary = new StringBuilder(); foreach (var view in report.GetWidgetViews()) { summary.AppendFormat("Widget '{0}' in View '{1}' of Type '{2}'\r\n", view.WidgetDefinition.Name, view.Name, view.TemplateName); } log.Log("Report: '{0}' ({1}):\r\n{2}", report.ExecutionName, path, summary); } if (DashboardWidgetsPool.Widgets.Count == 0) { log.Log("No Widget published in this repository.\r\n"); } } catch (Exception ex) { log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message); } }
public ActionResult SWILogin(string user, string password, string token) { writeDebug("SWILogin"); try { if (WebUser == null || !WebUser.IsAuthenticated || (!string.IsNullOrEmpty(user) && WebUser.WebUserName != user) || (!string.IsNullOrEmpty(token) && WebUser.Token != token)) { CreateRepository(); CreateWebUser(); WebUser.WebPrincipal = User; WebUser.WebUserName = user; WebUser.WebPassword = password; WebUser.Token = token; Authenticate(); if (!WebUser.IsAuthenticated) { throw new LoginException(string.IsNullOrEmpty(WebUser.Error) ? Translate("Invalid user name or password") : WebUser.Error); } } //Audit Audit.LogAudit(AuditType.Login, WebUser); Audit.LogEventAudit(AuditType.EventLoggedUsers, SealSecurity.LoggedUsers.Count(i => i.IsAuthenticated).ToString()); //Set culture from cookie string culture = getCookie(SealCultureCookieName); if (!string.IsNullOrEmpty(culture)) { Repository.SetCultureInfo(culture); } //Set default view string view = getCookie(SealLastViewCookieName); if (string.IsNullOrEmpty(view)) { view = "reports"; } //Check rights if (WebUser.ViewType == Seal.Model.ViewType.Reports && view == "dashboards") { view = "reports"; } else if (WebUser.ViewType == Seal.Model.ViewType.Dashboards && view == "reports") { view = "dashboards"; } //Refresh widgets DashboardWidgetsPool.ForceReload(); DashboardExecutions.Clear(); return(Json(new SWIUserProfile() { name = WebUser.Name, group = WebUser.SecurityGroupsDisplay, culture = Repository.CultureInfo.EnglishName, folder = getCookie(SealLastFolderCookieName), dashboard = getCookie(SealLastDashboardCookieName), viewtype = WebUser.ViewType, lastview = view, dashboardfolders = WebUser.DashboardFolders.ToArray(), managedashboards = WebUser.ManageDashboards, usertag = WebUser.Tag })); } catch (Exception ex) { return(HandleSWIException(ex)); } }