public void Update(FileConfiguration item)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<FileConfiguration>();
         rep.Update(item);
     }
 }
        protected void lbnOK_Click(object sender, EventArgs e)
        {
            //ensure path works before saving changes
            if (!VerifyPath())
                return;

            try
            {
                FileConfigurationController ctrl = new FileConfigurationController();
                List<FileConfiguration> configs = ctrl.GetItems(PortalId) as List<FileConfiguration>;
                FileConfiguration config = null;
                if (configs.Count > 0)
                {
                    config = configs[0];
                }
                else
                {
                    config = new FileConfiguration();
                    config.ID = -1;
                }

                config.FilesLocation = txtFilesLocation.Text;
                config.LastModifiedByUserName = UserInfo.DisplayName;
                config.LastModifiedDate = System.DateTime.Now;
                config.PortalID = PortalId;
                config.StorageType = radStorageLocation.SelectedValue;

                if (config.ID == -1)
                {
                    ctrl.Create(config);
                }
                else
                {
                    ctrl.Update(config);
                }

                //refresh cac
                SynchronizeModule();

                //Redirect back to the portal home page
                this.Response.Redirect(Globals.NavigateURL(), true);
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
示例#3
0
        private void populateChildren(System.Web.UI.WebControls.TreeNode parentNode, int searchValue, FileConfiguration config)
        {
            if (parentNode == null)
                return;

            //get folders
            FileController fileCtrl = new FileController();
            List<File> listFiles = fileCtrl.GetItemsByParent(Convert.ToInt32(parentNode.Value), UserId, PortalId, PortalSettings.AdministratorRoleId, "Asc") as List<File>;

            foreach (File file in listFiles)
            {
                //Skip getting child items if:
                //item is not folder || item is a folder and matches target item || item can't be modified
                if (file.ItemType != 0 || !file.CanModify(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
                {
                    continue;
                }

                System.Web.UI.WebControls.TreeNode fileChild;

                //check for protected folders
                if (file.ID == config.RootUsersFolderID || file.ID == config.RootGroupsFolderID || file.ID == config.RootSharedFolderID)
                {
                    file.Name = file.Name + " (protected)";
                    fileChild = new System.Web.UI.WebControls.TreeNode(file.Name, file.ID.ToString(), "images/lock_16_hot.png");
                }
                else
                {
                    fileChild = new System.Web.UI.WebControls.TreeNode(file.Name, file.ID.ToString(), "images/folder_16_hot.png");
                }

                if (parentNode != null)
                {
                    //fileChild.PopulateOnDemand = true;
                    fileChild.Expanded = false;
                    parentNode.ChildNodes.Add(fileChild);
                    populateChildren(fileChild, searchValue, config);

                    if (fileChild.Value == searchValue.ToString())
                    {
                        fileChild.Selected = true;
                        ExpandParentNode(fileChild);
                    }
                }
            }
        }