public ActionResult GetState() { try { var parlourPath = Settings.UserParlourPath; var session = new PrivateSession().Current; _log.AddInfo("GetState", "User: "******" IsAuthenticated: " + User.Identity.IsAuthenticated); if (session.User != null) { if (session.User.IsAdmin) { parlourPath = Settings.AdminParlourPath; } if (session.User.IsModerator) { parlourPath = Settings.ModeratorParlourPath; } return(Json(new { IsEnabled = true, IsAuthanticated = session.User.IsEnabled, ImagePath = !string.IsNullOrEmpty(session.User.UserLogoPath) ? session.User.UserLogoPath : Settings.DefaulLogoPath, UserName = session.User.Name, ParlourPath = parlourPath, SessionId = session.User.Id, Groups = session.User.SubscribeToGroups })); } if (!User.Identity.IsAuthenticated) { return(Json(new { IsEnabled = false, IsAuthanticated = false, ImagePath = (string)null, ParlourPath = (string)null })); } session.User = _user.GetUserInfo(Guid.Parse(User.Identity.Name)); if (session.User.IsAdmin) { parlourPath = Settings.AdminParlourPath; } if (session.User.IsModerator) { parlourPath = Settings.ModeratorParlourPath; } return(Json(new { IsEnabled = true, IsAuthanticated = session.User.IsEnabled, ImagePath = !string.IsNullOrEmpty(session.User.UserLogoPath) ? session.User.UserLogoPath : Settings.DefaulLogoPath, UserName = session.User.Name, ParlourPath = parlourPath, SessionId = session.User.Id, Groups = session.User.SubscribeToGroups })); } catch (Exception ex) { _log.AddError("GetState", ex.Message); return(Json(new { IsEnabled = false, IsAuthanticated = false, ImagePath = (string)null, ParlourPath = (string)null })); } }
protected void AddFiles(string source, string target, IEnumerable <string> filenames) { foreach (var filename in filenames) { var targetPath = Path.Combine(target, filename); var targetDir = Path.GetDirectoryName(targetPath); if (!Directory.Exists(targetDir)) { Directory.CreateDirectory(targetDir); } File.Copy(Path.Combine(source, filename), targetPath); Log.AddInfo(filename); } }