Beispiel #1
0
 public object OnDownload(ISession session, Download e)
 {
     try
     {
         CurrentFolder folder   = GetFolder(session);
         string        filename = folder.Path + e.File;
         if (!System.IO.File.Exists(filename))
         {
             return(new Error {
                 Message = e.File + " not found!"
             });
         }
         session["DOWNLOAD_TAG"] = new FileHelper(filename);
         System.IO.FileInfo fi = new System.IO.FileInfo(filename);
         return(new FileInfo {
             Name = fi.Name, Size = fi.Length
         });
     }
     catch (Exception e_)
     {
         return(new Error {
             Message = e_.Message
         });
     }
 }
Beispiel #2
0
        public object OnCD(ISession session, CD e)
        {
            try
            {
                "{0} CD {1}".Log4Info(session.Channel.EndPoint, e.Name);
                List <Resource> result = new List <Resource>();
                CurrentFolder   folder = GetFolder(session);
                if (e.Name == @"\")
                {
                    folder.Root();
                }
                else if (e.Name == "..")
                {
                    folder.Previous();
                }
                else if (!string.IsNullOrEmpty(e.Name))
                {
                    string name = folder.Path + e.Name;
                    if (System.IO.Directory.Exists(name))
                    {
                        folder.Add(e.Name);
                    }
                }
                else
                {
                }
                if (folder.SubFolder)
                {
                    result.Add(new Resource {
                        Name = @"\", Type = ResourceType.Folder
                    });
                    result.Add(new Resource {
                        Name = @"..", Type = ResourceType.Folder
                    });
                }
                foreach (string f in System.IO.Directory.GetDirectories(folder.Path))
                {
                    System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(f);

                    result.Add(new Resource {
                        Name = info.Name, Type = ResourceType.Folder
                    });
                }
                foreach (string f in System.IO.Directory.GetFiles(folder.Path))
                {
                    System.IO.FileInfo info = new System.IO.FileInfo(f);
                    result.Add(new Resource {
                        Name = info.Name, Type = ResourceType.File, Size = ((double)info.Length / (double)1024).ToString("0.00/KB")
                    });
                }
                return(result);
            }
            catch (Exception e_)
            {
                return(new Error {
                    Message = e_.Message
                });
            }
        }
Beispiel #3
0
        private CurrentFolder GetFolder(ISession session)
        {
            CurrentFolder result = (CurrentFolder)session["FOLDER"];

            if (result == null)
            {
                result            = new CurrentFolder(session.Application[AppModel.BASE_PATH].ToString());
                session["FOLDER"] = result;
            }
            return(result);
        }
Beispiel #4
0
 private CurrentFolder GetFolder(ISession session)
 {
     CurrentFolder result = (CurrentFolder)session["FOLDER"];
     if (result == null)
     {
         result = new CurrentFolder(session.Application[AppModel.BASE_PATH].ToString());
         session["FOLDER"] = result;
     }
     return result;
 }