Exemplo n.º 1
0
        private void RenamingComplete(object item)
        {
            if (!myContext.IsSubmitting)
            {
                IsSubmittingContext = true;

                IsUpdatingReportGroups = true;
                ReportGroupFolder folderToRename = item as ReportGroupFolder;
                if (folderToRename != null)
                {
                    //Adjust name for duplicates in same folder.
                    folderToRename = AdjustName(folderToRename, false);
                    int depth = 0;
                    if (folderToRename.Parent == null)
                    {
                        depth = 0;
                    }
                    else
                    {
                        depth = folderToRename.Parent.FullPath.Split('/').Count() - 1;
                    }
                    var reportToUpdate = myContext.ReportGroups.First(rg => rg.Code == folderToRename.Code);
                    reportToUpdate.PathName = folderToRename.FullPath;
                    reportToUpdate.Name     = folderToRename.Name;
                    UpdateChildPaths(folderToRename, folderToRename.Code, folderToRename.Name, depth);//, updateList);

                    myContext.SubmitChanges(FolderRenamedCallback, folderToRename);
                }
            }
        }
Exemplo n.º 2
0
        private void NewFolder(object item)
        {
            IsUpdatingReportGroups = true;
            IsSubmittingContext    = true;

            ReportGroupFolder folderToAddChild = item as ReportGroupFolder;

            if (folderToAddChild != null)
            {
                folderToAddChild.IsExpanded = true;
                //Do add child folder
                ReportGroupFolder foldertoAdd = new ReportGroupFolder()
                {
                    Code = Guid.NewGuid(), AccessLevel = ReportGroupAccessLevelType.Admin, Color = "Yellow", FullPath = folderToAddChild.FullPath + "New Folder/", IsExpanded = true, IsTemp = false, Name = "New Folder", Parent = folderToAddChild
                };
                //Adjust name for duplicates in same folder.
                foldertoAdd = AdjustName(foldertoAdd, true);

                //Do not add child to tree here or busyindicator will stop focus setting.
                //folderToAddChild.Children.Add(foldertoAdd);

                //sort reporting services;
                myContext.ReportGroups.Add(new ReportGroup()
                {
                    Code = foldertoAdd.Code, ReportType = "A", AccessLevel = ReportGroupAccessLevelType.Admin, Name = foldertoAdd.Name, ParentCode = foldertoAdd.Parent.Code, ParentPath = foldertoAdd.Parent.FullPath, PathName = foldertoAdd.Parent.FullPath + foldertoAdd.Name + "/"
                });
                myContext.SubmitChanges(NewFolderAddedCallback, foldertoAdd);
                //myContext.AddNewReportGroupForUser(new ReportGroupForUser() { Code = foldertoAdd.Code, AccessLevel = ReportGroupAccessLevelType.Admin, Name = foldertoAdd.Name, ParentCode = foldertoAdd.Parent.Code, ParentPath = foldertoAdd.Parent.FullPath, PathName = foldertoAdd.Parent.FullPath + foldertoAdd.Name + "/" }, NewFolderAddedCallback, foldertoAdd);
            }
        }
Exemplo n.º 3
0
        private void UpdateChildPaths(ReportGroupFolder group, Guid parentCode, String reportGroupName, int depth)//, List<ReportGroupForUser> updatedList)
        {
            IEnumerable <ReportGroupFolder> childGroups = group.Children.Where(x => x.Parent.Code == parentCode);

            foreach (ReportGroupFolder currentChild in childGroups)
            {
                string[] folderHierarchy = currentChild.FullPath.Split('/');
                folderHierarchy[depth] = reportGroupName;
                StringBuilder pathBuilder = new StringBuilder();
                foreach (string currentSegment in folderHierarchy)
                {
                    if (!string.IsNullOrEmpty(currentSegment))
                    {
                        pathBuilder.Append(currentSegment + "/");
                    }
                }
                currentChild.FullPath = pathBuilder.ToString();

                //Update the underlying entities
                var reportToUpdate = myContext.ReportGroups.First(rg => rg.Code == currentChild.Code);
                reportToUpdate.PathName   = currentChild.FullPath;
                reportToUpdate.ParentPath = currentChild.Parent.FullPath;
                reportToUpdate.Name       = currentChild.Name;

                UpdateChildPaths(currentChild, currentChild.Code, reportGroupName, depth);//,updatedList);
            }
        }
Exemplo n.º 4
0
        private void RenameFolder(object item)
        {
            ReportGroupFolder folderToRename = item as ReportGroupFolder;

            if (folderToRename != null)
            {
                folderToRename.IsRenaming = true;
            }
        }
 public static void MarshalMembers(ReportGroupFolder updatedFolder, ReportGroup newValues)
 {
     updatedFolder.AccessLevel = newValues.AccessLevel;
     //updatedFolder.Color = newValues.Color;
     updatedFolder.FullPath      = newValues.PathName;
     updatedFolder.IsTemp        = (newValues.Name == "Temp");
     updatedFolder.Name          = newValues.Name;
     updatedFolder.RowIdentifier = newValues.RowIdentifier;
 }
Exemplo n.º 6
0
        private bool CanChangeFolderPermissions(object item)
        {
            ReportGroupFolder folderToChange = item as ReportGroupFolder;

            if (folderToChange != null)
            {
                return(folderToChange.AccessLevel >= ReportGroupAccessLevelType.Admin);
            }
            return(false);
        }
Exemplo n.º 7
0
        private bool CanAddChildFolder(object item)
        {
            ReportGroupFolder folderToAddChild = item as ReportGroupFolder;

            if (folderToAddChild != null)
            {
                return(folderToAddChild.AccessLevel >= ReportGroupAccessLevelType.Update);
            }
            return(false);
        }
Exemplo n.º 8
0
        private bool CanRenamingComplete(object item)
        {
            ReportGroupFolder folderToRename = item as ReportGroupFolder;

            if (folderToRename != null)
            {
                return(folderToRename.AccessLevel >= ReportGroupAccessLevelType.Update);
            }
            return(false);
        }
        /// <summary>
        /// Create a TreeView that contains nodes populated from ReportGroup table
        /// </summary>
        /// <param name="rootTreeNodes">A TreeNodeCollection to be populated with
        /// report group nodes.</param>
        /// <param name="requiredAccessLevel">Required access level for this TreeView.</param>
        /// <param name="ReportGroupForUserList">List of ReportGroupForUser objects
        /// to use in populating the TreeView.</param>
        /// <param name="DisplayTempGroup">Indicates whether the Temp Folder should be displayed in the tree view.</param>
        public static void AssembleTreeView(IList <ReportGroupFolder> rootGroups,
                                            ReportGroupAccessLevelType requiredAccessLevel, List <ReportGroup> ReportGroupForUserList, bool DisplayTempGroup, Guid initialExpandedGroup)
        {
            ReportGroupForUserList = ReportGroupForUserList.OrderBy(x => x.ParentPath).ToList();
            foreach (ReportGroup CurrentReportGroupForUser in ReportGroupForUserList)
            {
                //Only display temp folder if true.
                if (CurrentReportGroupForUser.ParentPath == null)
                {
                    //Do not display temp group unless explicitly requested
                    if (CurrentReportGroupForUser.Name == "Temp" && DisplayTempGroup == false)
                    {
                        continue;
                    }

                    //add a root tree node
                    ReportGroupFolder NodeToAdd = new ReportGroupFolder();
                    NodeToAdd.Code     = CurrentReportGroupForUser.Code;
                    NodeToAdd.Name     = CurrentReportGroupForUser.Name;
                    NodeToAdd.FullPath = CurrentReportGroupForUser.Name + "/";
                    NodeToAdd.Parent   = null;
                    if (CurrentReportGroupForUser.Name == "Temp")
                    {
                        NodeToAdd.IsTemp = true;
                    }
                    NodeToAdd.AccessLevel = CurrentReportGroupForUser.AccessLevel;

                    //Temp folder must be Yellow.
                    if (CurrentReportGroupForUser.AccessLevel >= requiredAccessLevel ||
                        CurrentReportGroupForUser.Name == "Temp")
                    {
                        // Required access level is less than or equal to user
                        // access level, so show access granted folder
                        NodeToAdd.Color = "Yellow";
                    }
                    else
                    {
                        // Required access level must be greater than user access level, so
                        // image shows access denied folder
                        NodeToAdd.Color = "Gray";// ImageIndex = 2;
                    }

                    rootGroups.Add(NodeToAdd);
                }
                else
                {
                    //add a root tree node with all the child tree nodes
                    PopulateTreeViewRecursive(rootGroups, CurrentReportGroupForUser,
                                              requiredAccessLevel, initialExpandedGroup);
                }
            }
        }
Exemplo n.º 10
0
        private bool CanDeleteFolder(object item)
        {
            ReportGroupFolder folderToDelete = item as ReportGroupFolder;

            if (folderToDelete != null)
            {
                var deletingFolder = (from x in myContext.ReportGroups
                                      where x.Code == folderToDelete.Code
                                      select x).Single();
                return(deletingFolder.AccessLevel >= ReportGroupAccessLevelType.Delete && !IsRetreivingReports && (folderToDelete.Children == null || folderToDelete.Children.Count == 0) && deletingFolder.Reports.Count == 0);
            }
            return(false);
        }
Exemplo n.º 11
0
        private void FolderRenamedCallback(SubmitOperation so)
        {
            ReportGroupFolder folderToRename = so.UserState as ReportGroupFolder;

            TreeViewHelper.GetAccessLevels(WebContext.Current.User.Name, myContext.ReportGroups);
            if (so.HasError)
            {
            }
            else
            {
            }
            IsSubmittingContext       = false;
            folderToRename.IsRenaming = false;
            IsUpdatingReportGroups    = false;
        }
Exemplo n.º 12
0
        private void ChangeFolderPermissions(object item)
        {
            ReportGroupFolder folderToChange = item as ReportGroupFolder;

            if (folderToChange != null)
            {
                var dialog = SimpleServiceLocator.Instance.Get <IModalWindow>("ReportGroupPermissions");
                this.modalDialogService.ShowDialog(dialog, new ReportGroupPermissionsViewModel(folderToChange),
                                                   returnedViewModelInstance =>
                {
                    if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                    {
                        //SelectedDataModel = returnedViewModelInstance.SelectedDataModel;
                    }
                });
            }
        }
Exemplo n.º 13
0
        private void DeleteFolder(object item)
        {
            IsUpdatingReportGroups = true;
            IsSubmittingContext    = true;

            ReportGroupFolder folderToDelete = item as ReportGroupFolder;

            if (folderToDelete != null)
            {
                if (CanDeleteFolder(folderToDelete))
                {
                    var rgToDelete = myContext.ReportGroups.First(rg => rg.Code == folderToDelete.Code);
                    myContext.ReportGroups.Remove(rgToDelete);
                    myContext.SubmitChanges(FolderDeletedCallback, folderToDelete);
                    // myContext.DeleteReportGroupForUser(new ReportGroupForUser() { Code = folderToDelete.Code, AccessLevel = ReportGroupAccessLevelType.Admin, Name = folderToDelete.Name, ParentCode = folderToDelete.Parent.Code, ParentPath = folderToDelete.Parent.FullPath, PathName = folderToDelete.Parent.FullPath + folderToDelete.Name + "/" }, FolderDeletedCallback, folderToDelete);
                }
            }
        }
Exemplo n.º 14
0
        private void NewFolderAddedCallback(SubmitOperation so)
        {
            //turn busy indicator off
            IsUpdatingReportGroups = false;
            TreeViewHelper.GetAccessLevels(WebContext.Current.User.Name, myContext.ReportGroups);

            ReportGroupFolder folderToAdd = so.UserState as ReportGroupFolder;

            if (!so.HasError)
            {
                folderToAdd.Parent.Children.Add(folderToAdd);
            }
            else
            {
            }
            IsSubmittingContext     = false;
            folderToAdd.IsJustAdded = true;
        }
Exemplo n.º 15
0
        private ReportGroupFolder AdjustName(ReportGroupFolder folderToAdjust, bool isAdd)
        {
            int i = 0;

            if (folderToAdjust.Parent == null)
            {
                i = RootGroups.Count();
            }
            else
            {
                i = folderToAdjust.Parent.Children.Where(x => x.Name == folderToAdjust.Name).Count();
            }
            if ((i > 0 && isAdd) || (i > 1 && !isAdd))
            {
                folderToAdjust.Name     = folderToAdjust.Name + "(" + (i).ToString() + ")";
                folderToAdjust.FullPath = folderToAdjust.Parent.FullPath + folderToAdjust.Name + "/";
                folderToAdjust          = AdjustName(folderToAdjust, isAdd);
            }
            return(folderToAdjust);
        }
Exemplo n.º 16
0
        private void FolderDeletedCallback(SubmitOperation so)
        {
            ReportGroupFolder folderToDelete = so.UserState as ReportGroupFolder;

            if (!so.HasError)
            {
                if (!(folderToDelete.Parent == null))
                {
                    folderToDelete.Parent.Children.Remove(folderToDelete);
                }
                else
                {
                    this.RootGroups.Remove(folderToDelete);
                }
            }
            else
            {
            }
            //DeleteFolderCommand.UpdateCanExecuteCommand();
            IsUpdatingReportGroups = false;
            IsSubmittingContext    = false;
        }
        public ReportGroupPermissionsViewModel(ReportGroupFolder currentGroup)
        {
            OKButtonCommand     = new RelayCommand(cmd => OKButton(cmd), exe => CanOKButton(exe));
            ApplyButtonCommand  = new RelayCommand(cmd => ApplyButton(cmd), exe => CanApplyButton(exe));
            CancelButtonCommand = new RelayCommand(cmd => CancelButton(cmd));

            currentUser       = WebContext.Current.User;
            currentPermission = currentGroup.AccessLevel;
            permissions       = new ObservableCollection <string>();
            if (ReportGroupAccessLevelType.Admin <= currentPermission)
            {
                permissions.Add(ReportGroupAccessLevelType.Admin.ToString());
            }
            if (ReportGroupAccessLevelType.Delete <= currentPermission)
            {
                permissions.Add(ReportGroupAccessLevelType.Delete.ToString());
            }
            if (ReportGroupAccessLevelType.Update <= currentPermission)
            {
                permissions.Add(ReportGroupAccessLevelType.Update.ToString());
            }
            if (ReportGroupAccessLevelType.ReadOnly <= currentPermission)
            {
                permissions.Add(ReportGroupAccessLevelType.ReadOnly.ToString());
            }
            if (ReportGroupAccessLevelType.None <= currentPermission)
            {
                permissions.Add(ReportGroupAccessLevelType.None.ToString());
            }
            permissions.Add("Inherit");

            PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ReportGroupPermissionsViewModel_PropertyChanged);

            myContext.Load <MCUser>(myContext.GetAllMCUserQuery(), LoadBehavior.MergeIntoCurrent, GetAllUserCallback, null);
            myContext.Load <ReportGroup>(myContext.GetReportGroupByCodeQuery(currentGroup.Code), LoadBehavior.MergeIntoCurrent, GetReportGroupCallback, null);
        }
        private static bool PopulateTreeViewRecursive(IList <ReportGroupFolder> currentReportGroupChildren,
                                                      ReportGroup currentReportGroupForUser, ReportGroupAccessLevelType requiredAccessLevel, Guid initialExpandedGroup)
        {
            bool IsFoundNode = false;

            foreach (ReportGroupFolder currentReportGroup in currentReportGroupChildren)
            {
                if (currentReportGroup.FullPath == currentReportGroupForUser.ParentPath)
                {
                    ReportGroupFolder NodeToAdd = new ReportGroupFolder();

                    /* TIR0003 DMH - Access ia Parent Group has already been established.
                     * // If the user does not have an access level set it is inherited from its parent
                     * if (currentReportGroupForUser.AccessLevel == ReportGroupAccessLevelType.None)
                     * {
                     *  currentReportGroupForUser.AccessLevel =
                     *      ((ReportGroupForUser)currentTreeNode.Tag).AccessLevel;
                     * }
                     */

                    //Expand all tree nodes down to the initially selected one.
                    if (currentReportGroupForUser.Code == initialExpandedGroup)
                    {
                        NodeToAdd.IsExpanded = false;
                        ReportGroupFolder ParentReportGroup = currentReportGroup;
                        while (ParentReportGroup.Parent != null)
                        {
                            ParentReportGroup.IsExpanded = true;
                            ParentReportGroup            = ParentReportGroup.Parent;
                        }
                        ParentReportGroup.IsExpanded = true;
                    }


                    if (currentReportGroupForUser.AccessLevel < requiredAccessLevel)
                    {
                        //set folder icon to grey for folders that the users do not have access to
                        NodeToAdd.Color = "Gray";// SelectedImageIndex = 2;
                    }


                    if (currentReportGroupForUser.AccessLevel >= requiredAccessLevel)
                    {
                        // DBS Code Review Issue : 17/03/2005 - Need to change image colour
                        //DBS 31/03/2005 image changed to yellow
                        NodeToAdd.Color = "Yellow";
                        //go back up tree to set image colour to red if access not set
                        ReportGroupFolder ParentReportGroup = currentReportGroup;
                        //04/07/05 LL - TIR0178 - Root Parent Folder needs to be set to red image colour
                        //if not already yellow
                        if (ParentReportGroup.Parent == null)
                        {
                            if (ParentReportGroup.AccessLevel < requiredAccessLevel)
                            {
                                ParentReportGroup.Color = "Red";
                            }
                        }

                        //TIR0004 Set Parent group to Red only if not already yellow.
                        while (ParentReportGroup.Parent != null)
                        {
                            if (ParentReportGroup.AccessLevel < requiredAccessLevel)
                            {
                                ParentReportGroup.Color = "Red";
                            }
                            ParentReportGroup = ParentReportGroup.Parent;
                        }
                    }
                    //add node
                    NodeToAdd.Name        = currentReportGroupForUser.Name;
                    NodeToAdd.FullPath    = currentReportGroup.FullPath + currentReportGroupForUser.Name + "/";
                    NodeToAdd.Code        = currentReportGroupForUser.Code;
                    NodeToAdd.IsTemp      = (currentReportGroupForUser.Name == "Temp");
                    NodeToAdd.AccessLevel = currentReportGroupForUser.AccessLevel;
                    NodeToAdd.Parent      = currentReportGroup;
                    currentReportGroup.Children.Add(NodeToAdd);
                    IsFoundNode = true;
                }
                else
                {
                    IsFoundNode = PopulateTreeViewRecursive(currentReportGroup.Children,
                                                            currentReportGroupForUser, requiredAccessLevel, initialExpandedGroup);
                }
            }
            return(IsFoundNode);
        }