Example #1
0
 public CBFile(DirectoryInfo dir, UNCPath unc, User user)
 {
     Extension    = dir.Extension;
     Type         = "File Folder";
     Name         = dir.Name;
     Icon         = "images/icons/" + MyComputerItem.ParseForImage(dir);
     BType        = ComputerBrowser.BType.Folder;
     CreatedTime  = dir.CreationTime;
     ModifiedTime = dir.LastWriteTime;
     Path         = Converter.UNCtoDrive(dir.FullName, unc, user);
 }
Example #2
0
        public static UNCPath ToUNCPath(DriveMapping unc)
        {
            UNCPath Unc = new UNCPath();

            Unc.Drive         = unc.Drive.ToString();
            Unc.EnableReadTo  = unc.EnableReadTo;
            Unc.EnableWriteTo = unc.EnableWriteTo;
            Unc.Name          = unc.Name;
            Unc.UNC           = unc.UNC;
            Unc.Usage         = unc.UsageMode;
            return(Unc);
        }
Example #3
0
        public static string DriveToUNC(string RoutingPath, string RoutingDrive, out UNCPath unc)
        {
            DriveMapping u;
            string       s  = DriveToUNC(RoutingPath, RoutingDrive, out u);
            UNCPath      u1 = new UNCPath();

            u1.Drive         = u.Drive.ToString();
            u1.EnableReadTo  = u.EnableReadTo;
            u1.EnableWriteTo = u.EnableWriteTo;
            u1.Name          = u.Name;
            u1.UNC           = u.UNC;
            u1.Usage         = u.UsageMode;
            unc = u1;
            return(s);
        }
Example #4
0
        public CBFile(FileInfo file, UNCPath unc, User user)
        {
            Extension = file.Extension;
            Type      = "File";
            Name      = file.Name + (file.Name.Contains(file.Extension) ? "" : file.Extension);

            FileIcon fi;

            if (FileIcon.TryGet(Extension, out fi))
            {
                Type = fi.Type;
                Name = Name.Remove(Name.LastIndexOf(file.Extension));
            }
            if (Type == "File")
            {
                try
                {
                    RegistryKey rkRoot = Registry.ClassesRoot;
                    string      keyref = rkRoot.OpenSubKey(file.Extension).GetValue("").ToString();
                    Type = rkRoot.OpenSubKey(keyref).GetValue("").ToString();
                    Name = Name.Remove(Name.LastIndexOf(file.Extension));
                }
                catch { Type = "File"; }
            }
            if (Type != "File")
            {
                Icon = "images/icons/" + ParseForImage(file);
                if (Icon.EndsWith(".ico"))
                {
                    Icon = "api/mycomputer/" + ParseForImage(file);
                }
            }
            else
            {
                Icon = "images/icons/file.png";
            }
            if (file.Extension.ToLower().Equals(".png") || file.Extension.ToLower().Equals(".jpg") || file.Extension.ToLower().Equals(".jpeg") || file.Extension.ToLower().Equals(".gif") || file.Extension.ToLower().Equals(".bmp") || file.Extension.ToLower().Equals(".wmf"))
            {
                Icon = "api/mycomputer/thumb/" + Converter.UNCtoDrive2(file.FullName, unc, user).Replace('&', '^');
            }
            BType        = ComputerBrowser.BType.File;
            CreatedTime  = file.CreationTime;
            ModifiedTime = file.LastWriteTime;
            Size         = parseLength(file.Length);
            Path         = Converter.UNCtoDrive(file.FullName, unc, user);
        }
Example #5
0
 public FileCheckResponse(FileInfo file, UNCPath unc, User user)
 {
     Thumb = "images/icons/" + MyComputerItem.ParseForImage(file);
     if (file.Exists)
     {
         Code         = FileCheckResponseCode.Exists;
         FileName     = file.Name;
         Extension    = file.Extension;
         FilePath     = Converter.UNCtoDrive(file.FullName, unc, user);
         FileSize     = Converter.parseLength(file.Length);
         DateModified = file.LastWriteTime;
         DateCreated  = file.CreationTime;
     }
     else
     {
         Code = FileCheckResponseCode.OK;
     }
 }
Example #6
0
 static bool isWriteAuth(UNCPath path, User user)
 {
     if (path == null)
     {
         return(true);
     }
     if (path.EnableWriteTo == "All")
     {
         return(true);
     }
     else if (path.EnableWriteTo != "None")
     {
         bool vis = false;
         foreach (string s in path.EnableWriteTo.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
         {
             if (!vis)
             {
                 vis = user.IsMemberOf(GroupPrincipal.FindByIdentity(ADUtils.GetPContext(), s.Trim()));
             }
         }
         return(vis);
     }
     return(false);
 }
Example #7
0
 static bool isWriteAuth(UNCPath path)
 {
     if (path == null)
     {
         return(true);
     }
     if (path.EnableWriteTo == "All")
     {
         return(true);
     }
     else if (path.EnableWriteTo != "None")
     {
         bool vis = false;
         foreach (string s in path.EnableWriteTo.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
         {
             if (!vis)
             {
                 vis = Context.User.IsInRole(s.Trim());
             }
         }
         return(vis);
     }
     return(false);
 }
 public ComputerBrowserAPIItem(DirectoryInfo dir, UNCPath unc, User user, AccessControlActions access, [Optional, DefaultParameterValue("")] string download) : base(dir, unc, user)
 {
     AccessControl = access;
     Download      = download;
 }
Example #9
0
 public static string DriveToUNC(string Path, out UNCPath unc)
 {
     return(DriveToUNC(Path.Remove(0, 2), Path.Substring(0, 1), out unc));
 }
Example #10
0
 public static string UNCtoDrive2(string dirpath, UNCPath unc)
 {
     return(UNCtoDrive2(dirpath, unc, ((User)Membership.GetUser())));
 }
Example #11
0
 public static string UNCtoDrive2(string dirpath, UNCPath unc, User user)
 {
     dirpath = dirpath.Replace(Converter.FormatMapping(unc.UNC, user), unc.Drive.ToString());
     dirpath = dirpath.Replace('\\', '/').Replace("//", "/");
     return(dirpath);
 }
Example #12
0
 public static string UNCtoDrive(string dirpath, UNCPath unc, User user)
 {
     dirpath = dirpath.Replace(Converter.FormatMapping(unc.UNC, user), unc.Drive + ":");
     dirpath = dirpath.Replace("\\\\", "\\");
     return(dirpath);
 }
Example #13
0
 public FileCheckResponse(string path, UNCPath unc, User user)
     : this(new FileInfo(path), unc, user)
 {
 }