コード例 #1
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {

            if (Disable) return;
            var isInvalid = false;

            var account = new AccountInfo();
            var dao = new SecurityDao();

            if (String.IsNullOrEmpty(account.GetUserName()))
                isInvalid = true;
         
            if (!isInvalid)
            {
                var errorMessage = "";
                if (!dao.ValidLdapUser(account.GetUserName(), out errorMessage))
                    isInvalid = true;
            }

            if (isInvalid)
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Account", action = "Login", ReturnUrl = filterContext.HttpContext.Request.Url.PathAndQuery }));
                return;
            }

            base.OnActionExecuting(filterContext);
        }
コード例 #2
0
 public ActionResult Index()
 {
     var account = new AccountInfo();
     try
     {
         var profile = ProfileService.GetUserProfile(account.GetUserName());
         string imageFile = AppDomain.CurrentDomain.BaseDirectory + "/content/img/DefaultUser.png";
         var buffer = string.IsNullOrEmpty(profile.ProfilePicture) ? imageFile : profile.ProfilePicture;
         var model = new UserProfileModel()
         {
             FirstName = profile.FirstName,
             LastName = profile.LastName,
             FullName = profile.FullName,
             EmailAddress = profile.EmailAddress,
             MobilePhone = profile.MobilePhone,
             ProfilePicture = buffer,
             Notes = profile.Notes,
             Department = profile.Department,
             JobTitle = profile.JobTitle,
             FullProfileLink = ApplicationConfiguration.ProfileUri
         };
         ViewBag.Title = "My Profile";
         return View(model);
     }
     catch (Exception ex) { throw ex; }
 }
コード例 #3
0
        public ActionResult Index(bool isFirstLoad = false)
        {
            var output = new List<MenuModel>();
            var account = new AccountInfo();
           
            try
            {
                var errorMessage = "";
                if (!SecurityService.ValidLdapUser(account.GetUserName(),out errorMessage))
                    return RedirectToAction("Logout");
                

                var documents = MenuService.GetTopMenu();
                foreach (var model in documents)
                {

                    var menu = new MenuModel() { LibraryName = model.LibraryName, Name = model.Name, FolderPath = model.FolderPath, ControllerName = model.ControllerName, ActionName = model.ActionName, Type = model.Type, ImageSource = model.ImageSource, ToolTip = model.ToolTip };

                    foreach (var child in model.Children)
                    {
                        menu.Children.Add(new MenuModel() { LibraryName = child.LibraryName, Name = child.Name, FolderPath = child.FolderPath, ControllerName = child.ControllerName, ActionName = child.ActionName, Type = child.Type, ToolTip = child.ToolTip });
                    }
                    output.Add(menu);
                }
            }
            catch (Exception) { return RedirectToAction("Logout"); }

            return View(output);
        }
コード例 #4
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var account = new AccountInfo();
            var modules = UserModuleService.GetAllUserModuleByLdapUser(new UserModule() { LdapName = account.GetUserName() });
            var moduleList = ModuleService.GetAllModules();

            var moduleMenuList = new List<UserModuleDetails>();

            foreach (var module in moduleList)
            {
                moduleMenuList.AddRange(from userModule in modules
                    where userModule.ModuleId == module.Id
                    where userModule.IsAdd || userModule.IsEdit || userModule.IsApprover
                    select new UserModuleDetails()
                    {
                        LdapName = userModule.LdapName,
                        ModuleId = userModule.ModuleId, 
                        ModuleName = module.Name,
                        DisplayName = module.DisplayName, 
                        Icon = module.Icon, 
                        IsAdd = userModule.IsAdd, 
                        IsEdit = userModule.IsEdit,
                        IsApprover = userModule.IsApprover
                    });
            }
            filterContext.Controller.ViewBag.ModulesMenu = moduleMenuList;

        }
コード例 #5
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var account = new AccountInfo();
            var controller = (((filterContext)).Controller).ToString().Split('.')[
                (((filterContext)).Controller).ToString().Split('.').Length - 1].Replace("Controller","");
            //var currentUser = account.GetUserName();
            var modules = UserModuleService.GetAllUserModuleByLdapUser(new UserModule() { LdapName = account.GetUserName() });
            var moduleList = ModuleService.GetAllModules();

            var moduleMenuList = new List<UserModuleDetails>();

            foreach (var module in moduleList)
            {
                moduleMenuList.AddRange(from userModule in modules
                                        where userModule.ModuleId == module.Id
                                        where userModule.IsAdd || userModule.IsEdit || userModule.IsApprover
                                        select new UserModuleDetails()
                                        {
                                            LdapName = userModule.LdapName,
                                            ModuleId = userModule.ModuleId,
                                            ModuleName = module.Name,
                                            DisplayName = module.DisplayName,
                                            Icon = module.Icon,
                                            IsAdd = userModule.IsAdd,
                                            IsEdit = userModule.IsEdit,
                                            IsApprover = userModule.IsApprover
                                        });
            }
            moduleMenuList.Add(new UserModuleDetails { ModuleName = "LandingPage" });

            var notificationList = NotificationService.GetAllNotificationDetailsList(account.GetFullName());

            filterContext.Controller.ViewBag.NotificationModel = notificationList;

            filterContext.Controller.ViewBag.CountNotifications = notificationList.Count;

            if (moduleMenuList.Any(a => a.ModuleName.ToUpper().Equals(controller.ToUpper())) || controller.ToUpper() == "NOTIFICATION") return;
            filterContext.HttpContext.Response.StatusCode = 401;
            filterContext.Controller.TempData["ErrorMessage"] = "You do not have permission to access this section, Please contact administrator <a href='mailto:[email protected]'>Service Desk</a>";

            filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Error", action = "Error", area = "" }));

            filterContext.HttpContext.Response.Clear();
        }
コード例 #6
0
 public string GetUserName()
 {
     var account = new AccountInfo();
     return SecurityService.GetLoggedInUserName(account.GetUserName());
 }
コード例 #7
0
        public ActionResult Download(string documentName, string libraryName, string folderPath)
        {
            var accountInfo = new AccountInfo();
            var extArr = documentName.Split('.');
            var docWithoutExt = documentName.ReplaceWithEmpty("." + extArr[extArr.Length - 1]);
            var dirPath = ApplicationConfiguration.RemoveDirectoryNFileFromServer.StartWithSlash() + "/";
            var key = Guid.NewGuid();
            var guidFileName = key + "." + extArr[extArr.Length - 1];
            var document = new DocumentLibrary()
            {
                Name = documentName,
                FolderPath = folderPath,
                LibraryName = libraryName,
                LocalDirectoryPath = dirPath,
                GuidDocumentName = guidFileName
            };

            DocumentLibraryService.GetDocuments(document);
            var appKey = new ApplicationKey()
            {
                AppId = Guid.NewGuid(),
                Key = key,
                DocumentName = guidFileName,
                OriginalDocumentName = documentName,
                DocumentPath = dirPath,
                UserName = accountInfo.GetUserName(),
                CreatedDate = DateTime.Now,
                CreatedBy = accountInfo.GetUserName(),
                IsDeleted = false,
                LastUpdatedDate = DateTime.Now,
                LastUpdatedBy = accountInfo.GetUserName(),
                CurrentPage = 1,
                StatusId = (int)ProcessorStatus.UnProcessed
            };
            ApplicationKeyService.InsertApplicationKey(appKey);
            appKey = ApplicationKeyService.GetApplicationKey(appKey);
            appKey.DocumentName = docWithoutExt;

            ViewBag.Folder = appKey.Key.ToString();
            ViewBag.TotalPages = appKey.PageCount;
            ViewBag.DocumentName = appKey.DocumentName;
            return View("Viewer");
        }
コード例 #8
0
 public ActionResult MyProfile()
 {
     var account = new AccountInfo();
     var userName = account.GetUserName();
     try
     {
         var profile = ProfileService.GetUserProfile(userName);
         userName = userName.ToUpper().Contains(ApplicationConfiguration.Domain.ToUpper())
             ? userName
             : ApplicationConfiguration.Domain + userName.StartWithBackwardSlash();
         string imageFile = AppDomain.CurrentDomain.BaseDirectory + "/content/img/DefaultUser.png";
         var buffer = string.IsNullOrEmpty(profile.ProfilePicture) ? imageFile : profile.ProfilePicture;
         var model = new UserProfileModel()
         {
             FirstName = profile.FirstName,
             LastName = profile.LastName,
             FullName = profile.FullName,
             EmailAddress = profile.EmailAddress,
             MobilePhone = profile.MobilePhone,
             ProfilePicture = buffer,
             Notes = profile.Notes,
             Department = profile.Department,
             JobTitle = profile.JobTitle,
             FullProfileLink = ApplicationConfiguration.ModernProfileUri + "?accountname=" + userName
         };
         ViewBag.Title = "Profile";
         ViewBag.AdvanceSearch = "True";
         return View("Index", model);
     }
     catch (Exception ex) { throw ex; }
 }
コード例 #9
0
 public string MyName()
 {
     var account = new AccountInfo();
     var profile = ProfileService.GetUserProfile(account.GetUserName());
     return profile.FirstName;
 }
コード例 #10
0
        private void RemoveChildForums(ForumsDetailsModel forums)
        {
            var account = new AccountInfo();
            SetFullNameAndEmail();

            foreach (var forumItem in forums.SubForums)
            {
                var subscriptionModel = new Subscription()
                {
                    CreatedBy = account.GetFullName(),
                    EmployeeName = account.GetUserName(), //User.Identity.Name.Replace("\\", "/"),
                    ForumName = forumItem.ForumFullPath,
                    IsActive = true,
                    IsDeleted = false,
                    IsSubscribed = true,
                };
                subscriptionModel = ForumSubscriptionService.GetSubscriptions(subscriptionModel);
                if (subscriptionModel != null)
                {
                    subscriptionModel.IsActive = false;
                    subscriptionModel.IsDeleted = true;
                    ForumSubscriptionService.UpdateSubscription(subscriptionModel);
                }
                if (forumItem.SubForums.Count > 0)
                    RemoveChildForums(forumItem);
            }
        }
コード例 #11
0
        private void WriteChildForums(ForumsDetailsModel forums, string email)
        {
            var account = new AccountInfo();
            SetFullNameAndEmail();
            foreach (var forumItem in forums.SubForums)
            {
                var subscriptionModel = new Subscription()
                 {
                     CreatedBy = account.GetFullName(),
                     EmployeeEmail = account.GetEmailAddress(),
                     EmployeeName = account.GetUserName(), //User.Identity.Name.Replace("\\", "/"),
                     ForumName = forumItem.ForumFullPath,
                     IsActive = true,
                     IsDeleted = false,
                     IsSubscribed = true,
                     CreatedDate = DateTime.Now
                 };
                ForumSubscriptionService.InsertSubscription(subscriptionModel);

                if (forumItem.SubForums.Count > 0)
                    WriteChildForums(forumItem, email);
            }
        }
コード例 #12
0
        private void WriteUpdateSubscription(string forumName, string email, string isSubscribed, bool subscribeParentOnly)
        {
            var account = new AccountInfo();
            SetFullNameAndEmail();

            #region Subscription database writing
            if (isSubscribed == "True")
            {
                var output = ConvertToForumDetailsListModel(ForumService.GetListofForums(forumName));
                var forum = new ForumsDetailsModel();
                forum.SubForums.AddRange(output);
                forum = null;
                var names = forumName.ForumSplit();
                foreach (var item in names)
                {
                    forum = (forum == null) ? output.FirstOrDefault(x => x.DisplayName == item) : forum.SubForums.FirstOrDefault(x => x.DisplayName == item);
                }

                var subscriptionModel = new Subscription()
                                        {
                                            CreatedBy = account.GetFullName(),
                                            EmployeeEmail = account.GetEmailAddress(),//email,
                                            EmployeeName = account.GetUserName(), //User.Identity.Name.Replace("\\", "/"),
                                            ForumName = forumName,
                                            IsActive = true,
                                            IsDeleted = false,
                                            IsSubscribed = true,
                                            CreatedDate = DateTime.Now
                                        };
                ForumSubscriptionService.InsertSubscription(subscriptionModel);
                if (!subscribeParentOnly)
                {
                    foreach (var forumItem in forum.SubForums)
                    {
                        subscriptionModel = new Subscription()
                        {
                            CreatedBy = account.GetFullName(),
                            EmployeeEmail = account.GetEmailAddress(),
                            EmployeeName = account.GetUserName(), //User.Identity.Name.Replace("\\", "/"),
                            ForumName = forumItem.ForumFullPath,
                            IsActive = true,
                            IsDeleted = false,
                            IsSubscribed = true,
                            CreatedDate = DateTime.Now
                        };
                        ForumSubscriptionService.InsertSubscription(subscriptionModel);

                        WriteChildForums(forumItem, email);
                    }
                }
                ForumSubscriptionService.SubscriptionRequestMail(forumName.ForumSplit().ForumJoin(), account.GetEmailAddress(), true);
            }
            #endregion

            #region un-Subscription database writing
            else if (isSubscribed == "False" && !subscribeParentOnly)
            {
                var output = ConvertToForumDetailsListModel(ForumService.GetListofForums(forumName));
                var forum = new ForumsDetailsModel();
                forum.SubForums.AddRange(output);
                forum = null;
                var names = forumName.ForumSplit();
                foreach (var item in names)
                {
                    forum = (forum == null) ? output.FirstOrDefault(x => x.DisplayName == item) : forum.SubForums.FirstOrDefault(x => x.DisplayName == item);
                }

                var subscriptionModel = new Subscription()
                {
                    CreatedBy = account.GetFullName(),
                    EmployeeEmail = account.GetEmailAddress(),
                    EmployeeName = account.GetUserName(), //User.Identity.Name.Replace("\\", "/"),
                    ForumName = forumName,
                    IsActive = true,
                    IsDeleted = false,
                    IsSubscribed = true,
                };
                subscriptionModel = ForumSubscriptionService.GetSubscriptions(subscriptionModel);
                if (subscriptionModel != null)
                {
                    subscriptionModel.IsActive = false;
                    subscriptionModel.IsDeleted = true;

                    ForumSubscriptionService.UpdateSubscription(subscriptionModel);
                }
                foreach (var forumItem in forum.SubForums)
                {
                    subscriptionModel = new Subscription()
                    {
                        CreatedBy = account.GetFullName(),
                        EmployeeEmail = account.GetEmailAddress(),
                        EmployeeName = account.GetUserName(), //User.Identity.Name.Replace("\\", "/"),
                        ForumName = forumItem.ForumFullPath,
                        IsActive = true,
                        IsDeleted = false,
                        IsSubscribed = true,
                    };
                    subscriptionModel = ForumSubscriptionService.GetSubscriptions(subscriptionModel);
                    if (subscriptionModel != null)
                    {
                        subscriptionModel.IsActive = false;
                        subscriptionModel.IsDeleted = true;

                        ForumSubscriptionService.UnsubscribeAllSubscriptions(subscriptionModel);
                    }
                    RemoveChildForums(forumItem);
                }
                ForumSubscriptionService.SubscriptionRequestMail(forumName.ForumSplit().ForumJoin(), account.GetEmailAddress(), false);
            }
            #endregion
        }
コード例 #13
0
 private void SetFullNameAndEmail()
 {
     SetUserFullName();
     var account = new AccountInfo();
     if (String.IsNullOrEmpty(account.GetEmailAddress()))
         account.SetEmailAddress(SecurityService.GetLoggedInUserEmailAddress(account.GetUserName()));
 }
コード例 #14
0
 private void SetUserFullName()
 {
     var account = new AccountInfo();
     if (String.IsNullOrEmpty(account.GetFullName()))
         account.SetFullName(SecurityService.GetLoggedInUserName(account.GetUserName()));
 }
コード例 #15
0
        private ForumsDetailsModel ConvertToForumDetailsModel(ForumsDetails forums)
        {
            var account = new AccountInfo();
            var accounType = typeof(AccountInfo);
            account.Department = account.GetDepartment();
            account.physicalDeliveryOfficeName = account.GetLocation();

            var forumDetails = GetForumsDetailsModel(forums);
            var subscription = ForumSubscriptionService.GetAllSubscriptions();
            var departmentForum = ForumActiveDirectoryMappingService.GetForumDepartmentMappings(accounType.GetProperty("Department").Name, account.GetDepartment());
            var locationForum = ForumActiveDirectoryMappingService.GetForumDepartmentMappings(accounType.GetProperty("physicalDeliveryOfficeName").Name, account.GetLocation());

            var nodeIsSubscribed = false;
            foreach (var subscriptionItem in subscription)
            {
                if (subscriptionItem.EmployeeName == account.GetUserName() && subscriptionItem.ForumName == forums.ForumFullPath)
                    nodeIsSubscribed = subscriptionItem.IsSubscribed;
            }
            forumDetails.IsSubscribed = nodeIsSubscribed;
            foreach (var names in departmentForum)
            {
                if (names == forums.ForumFullPath)
                    forumDetails.Department = names;
            }
            foreach (var location in locationForum)
            {
                if (location == forums.ForumFullPath)
                    forumDetails.Department = location;
            }
            forumDetails.CommentCount = forums.CommentCount;
            return forumDetails;
        }
コード例 #16
0
 private ForumsDetailsModel GetForumsDetailsModel(ForumsDetails forums)
 {
     var account = new AccountInfo();
     SetFullNameAndEmail();
     string imageFile = AppDomain.CurrentDomain.BaseDirectory + "/content/img/DefaultUser.png";
     var buffer = string.IsNullOrEmpty(forums.ProfileImgUrl) ? imageFile : forums.ProfileImgUrl;
     return new ForumsDetailsModel()
     {
         Name = forums.Name,
         DisplayName = forums.Name,
         LibraryName = forums.LibraryName,
         FolderPath = forums.FolderPath,
         Body = forums.Body,
         Id = forums.Id,
         CreatedBy = forums.CreatedBy,
         EditedBy = forums.EditedBy,
         CreatedDate = forums.CreatedDate,
         ParentFolderPath = forums.ParentFolderPath,
         TrimmedBody = forums.TrimmedBody,
         Replies = forums.Replies,
         LastUpdated = forums.LastUpdated,
         ModifiedDate = forums.ModifiedDate,
         ParentId = forums.ParentId,
         Permission = new SPPermissionModel() { CanAdd = forums.Permission.CanAdd },
         RootReply = forums.RootReply,
         Type = forums.Type,
         ProfileImgUrl = buffer,
         ForumFullPath = forums.ForumFullPath,
         EmployeeName = account.GetUserName(),  //User.Identity.Name,
         EmployeeEmail = account.GetEmailAddress(),
         IsSubscribed = false
     };
 }