public static void AddFolder(Folder folder)
 {
     try
     {
         FileMangerDataProvider.AddFolder(folder);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 2
0
 public static void AddRootFolder(Folder folder)
 {
     List<KeyValuePair<string, object>> ParaMeterCollection = new List<KeyValuePair<string, object>>();
     ParaMeterCollection.Add(new KeyValuePair<string, object>("@PortalId", folder.PortalId));
     ParaMeterCollection.Add(new KeyValuePair<string, object>("@FolderPath", folder.FolderPath));
     ParaMeterCollection.Add(new KeyValuePair<string, object>("@StorageLocation", folder.StorageLocation));
     ParaMeterCollection.Add(new KeyValuePair<string, object>("@UniqueId", folder.UniqueId));
     ParaMeterCollection.Add(new KeyValuePair<string, object>("@VersionGuid", folder.VersionGuid));
     ParaMeterCollection.Add(new KeyValuePair<string, object>("@IsActive", folder.IsActive));
     ParaMeterCollection.Add(new KeyValuePair<string, object>("@AddedBy", folder.AddedBy));
     SQLHandler sagesql = new SQLHandler();
     sagesql.ExecuteNonQuery("usp_FileManagerAddRootFolder", ParaMeterCollection);
 }
        public static int AddFolderReturnFolderID(Folder folder)
        {
            try
            {
                return (FileMangerDataProvider.AddFolderReturnFolderID(folder));
            }
            catch (Exception)
            {

                throw;

            }

        }
Ejemplo n.º 4
0
        public static int AddFolderReturnFolderID(Folder folder)
        {
            List<KeyValuePair<string, object>> ParaMeterCollection = new List<KeyValuePair<string, object>>();
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@PortalId", folder.PortalId));
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@ParentFolderID", folder.ParentID));
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@FolderPath", folder.FolderPath));
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@StorageLocation", folder.StorageLocation));
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@UniqueId", folder.UniqueId));
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@VersionGuid", folder.VersionGuid));
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@IsActive", folder.IsActive));
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@AddedBy", folder.AddedBy));
            SQLHandler sagesql = new SQLHandler();
            int FolderID = sagesql.ExecuteNonQueryAsGivenType<int>("[usp_FileManagerAddFolderRetFolderID]", ParaMeterCollection, "@FolderID");

            return FolderID;

        }
Ejemplo n.º 5
0
        public static void RecurseThroughDirectory(DirectoryInfo di,int folderId,int folderType)
        {
            FileInfo[] files = di.GetFiles();
            foreach (FileInfo fi in files)
            {
                List<ATTFile> lstFile = FileManagerController.GetFiles(folderId);
                bool exists = false;
                int size = int.Parse(fi.Length.ToString());
                if(Path.GetExtension(fi.Name)==".resources")
                {
                     exists= lstFile.Exists(
                        delegate(ATTFile obj)
                        {
                            return (obj.FileName == Path.GetFileNameWithoutExtension(fi.Name) && obj.FolderId == folderId);
                        }
                        );
                    
                }
                else
                {
                    exists = lstFile.Exists(
                    delegate(ATTFile obj)
                    {
                        return (obj.FileName == fi.Name && obj.FolderId == folderId);
                    }
                    );
                
                }
                if(!exists)
                {
                    //Add file to database
                    if (folderType == 1)
                    {
                        File.Move(fi.FullName,fi.FullName+".resources");
                        ATTFile fileObj = new ATTFile(fi.Name, FileManagerHelper.ReplaceBackSlash(GetFolderPath(di.FullName.Replace(absolutePath, ""))), folderId, UserName, Path.GetExtension(fi.Name.Replace(".resources", "")), PortalID, Guid.NewGuid(), Guid.NewGuid(),size, FileManagerHelper.ReturnExtension(Path.GetExtension(fi.Name.Replace(".resources", ""))), 1,folderType);
                        FileManagerController.AddFile(fileObj);
                    }
                    else
                    {   if(IsExtensionValid(Path.GetExtension(fi.Name)))
                        {
                        ATTFile fileObj = new ATTFile(fi.Name, FileManagerHelper.ReplaceBackSlash(GetFolderPath(di.FullName.Replace(absolutePath, ""))), folderId, UserName, Path.GetExtension(fi.Name), PortalID, Guid.NewGuid(), Guid.NewGuid(), int.Parse(fi.Length.ToString()), FileManagerHelper.ReturnExtension(Path.GetExtension(fi.Name)), 1, 0);
                        FileManagerController.AddFile(fileObj);
                        }
                    }

                   
                    
                }
            }
            foreach (DirectoryInfo di_child in di.GetDirectories())
            {
                int newFolderId = 0;
                int storageLocation = 0;
                int index = lstFolders.FindIndex(
                    delegate (Folder obj)
                        {
                            return (obj.FolderPath == GetFolderPath(di_child.FullName));
                        }
                    );
                if(index==-1)
                {
                    //Add folder to the database and get the folderId into newFolderId
                    Folder folder = new Folder();
                    folder.PortalId = PortalID;
                    folder.FolderPath = FileManagerHelper.ReplaceBackSlash(GetFolderPath(di_child.FullName));
                    folder.StorageLocation = storageLocation;
                    folder.UniqueId = Guid.NewGuid();
                    folder.VersionGuid = Guid.NewGuid();
                    folder.IsActive = 1;
                    folder.AddedBy = UserName;
                    folder.IsRoot = false;
                    newFolderId = FileManagerController.AddFolderReturnFolderID(folder);
                }
                else if(index>-1)
                {
                    newFolderId = lstFolders[index].FolderId;
                    storageLocation = lstFolders[index].StorageLocation;
                }
                RecurseThroughDirectory(di_child,newFolderId,storageLocation);
            }
            
        }
Ejemplo n.º 6
0
        public static List<Folder> GetFolders()
        {
            List<Folder> lstFolders = new List<Folder>();
            string StoredProcedureName = "usp_FileManagerGetFolders";
            SqlDataReader SQLReader;
            SQLHandler sagesql = new SQLHandler();
            try
            {
               
                SQLReader = sagesql.ExecuteAsDataReader(StoredProcedureName);
                while (SQLReader.Read())
                {
                    Folder obj = new Folder();
                    obj.FolderId = int.Parse(SQLReader["FolderId"].ToString());
                    obj.FolderPath = SQLReader["FolderPath"].ToString();
                    obj.StorageLocation = int.Parse(SQLReader["StorageLocation"].ToString());
                    lstFolders.Add(obj);
                }
                SQLReader.Dispose();
            }
            catch (Exception e)
            {
                throw e;
            }
             

            return lstFolders;
        }
        /// <summary>
        /// Connects to database and obtains active root folders.
        /// </summary>
        /// <returns>List of Folder class containing FolderId,FolderPath,StorageLocation and IsActive.</returns>
        public static List<Folder> GetActiveRootFolders()
        {
            List<Folder> lstFolders = new List<Folder>();
            string StoredProcedureName = "usp_FileManagerGetActiveRootFolders";
            SqlDataReader SQLReader = null;
            try
            {

                SQLHandler sagesql = new SQLHandler();
                SQLReader = sagesql.ExecuteAsDataReader(StoredProcedureName);
                while (SQLReader.Read())
                {
                    Folder obj = new Folder();
                    obj.FolderId = int.Parse(SQLReader["FolderId"].ToString());
                    obj.FolderPath = SQLReader["FolderPath"].ToString();
                    obj.StorageLocation = int.Parse(SQLReader["StorageLocation"].ToString());
                    obj.IsEnabled = bool.Parse(SQLReader["IsActive"].ToString());
                    lstFolders.Add(obj);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (SQLReader != null)
                {
                    SQLReader.Close();
                }
            }

            return lstFolders;
        }
        protected void AddRootFolder(string path)
        {
            Folder folder = new Folder();
            folder.PortalId = GetPortalID;
            folder.FolderPath = path.Replace(BaseDir + "/", "");
            folder.StorageLocation = 0;
            folder.UniqueId = Guid.NewGuid();
            folder.VersionGuid = Guid.NewGuid();
            folder.IsActive = 1;
            folder.AddedBy = GetUsername;
            try
            {
                FileManagerController.AddRootFolder(folder);
                CacheHelper.Clear("FileManagerRootFolders");
                CacheHelper.Clear("FileManagerFolders");
                GetRootFolders();
            }
            catch (Exception)
            {

                throw;
            }

        }