Пример #1
0
        public FolderWindow(IPlatformFolder folder, bool newFolder)
        {
            InitializeComponent();

            _isNewFolder = newFolder;
            if (!newFolder)
            {
                Title = "Folder Details";
                ConfirmButtonContent = "Save Changes";
                FolderNameTextBox.Text = folder.Name;
                FolderNameTextBox.BorderThickness = new Thickness(0, 0, 0, 0);
            }
            else
            {
                ConfirmButtonContent = "Create";
                FolderNameTextBox.Focus();
                FolderNameTextBox.BorderThickness = new Thickness(1, 1, 1, 1);
                FolderNameTextBox.SetValue(Grid.ColumnSpanProperty, 4);
                
                EditFolderNameImage.Visibility = Visibility.Collapsed;
            }

            _view = new FolderViewModel(folder, newFolder);
            DataContext = _view;

            FolderNameTextBox.TextChanged += OnFolderNameTextChanged;
            FolderNameTextBox.GotFocus += OnFolderNameGotFocus;
        }
Пример #2
0
        public IPlatformFile Upload(string fileName, string displayName, IPlatformFolder folder, string groupUuid = "")
        {
            var isChunking = IsChunking(fileName);

            var data = CreateVersion(fileName, displayName, folder, isChunking);
            var versionId = data.SelectToken("id").Value<string>();
            OfficePropertiesInterop.UpdateProperty(fileName, "WorkshareVersionId", versionId);

            if (!string.IsNullOrEmpty(groupUuid))
            {
                OfficePropertiesInterop.UpdateProperty(fileName, "WorkshareGroupUuid", groupUuid);
                OfficePropertiesInterop.UpdateProperty(fileName, "WorkshareFileId", data.SelectToken("file_id").Value<string>());
            }

            if (IsChunking(fileName))
            {
                UploadFileInChunks(fileName, data);
            }
            else
            {
                UploadWholeFile(fileName, data.SelectToken("complete_file").SelectToken("upload"));
            }

            var file = FinalizeUpload(data.SelectToken("id").Value<long>());

            file.VersionId = data.SelectToken("id").Value<int>();
            file.ParentId = folder.Id;
            return file;
        }
Пример #3
0
        public void GetApplicationFolderReturnsNullWhenCustomFolderConfiguredAndNotExists()
        {
            DirectoryInfo localAppData = this.CreateTestDirectory(@"AppData\Local");
            DirectoryInfo temp         = this.CreateTestDirectory(@"AppData\Temp");
            DirectoryInfo customFolder = new DirectoryInfo(@"Custom");

            Assert.IsFalse(customFolder.Exists);
            try
            {
                var environmentVariables = new Hashtable();
                environmentVariables.Add("LOCALAPPDATA", localAppData.FullName);
                environmentVariables.Add("TEMP", localAppData.FullName);
                var             provider          = new ApplicationFolderProvider(environmentVariables, customFolder.FullName);
                IPlatformFolder applicationFolder = provider.GetApplicationFolder();

                // VALIDATE
                // That the applicationfolder returned is null.
                Assert.IsNull(applicationFolder);

                // Also validate that SDK does not
                // create the customFolder.
                Assert.IsFalse(customFolder.Exists);
            }
            finally
            {
                DeleteIfExists(localAppData);
                DeleteIfExists(temp);
                DeleteIfExists(customFolder);
            }
        }
Пример #4
0
        public void GetApplicationFolderReturnsSubfolderFromVarTmpIfTmpDirIsTooLongInNonWindows()
        {
            if (!ApplicationFolderProvider.IsWindowsOperatingSystem())
            {
                string longDirectoryName = Path.Combine(this.testDirectory.FullName, new string('A', 300));
                var    varTmpdir         = new System.IO.DirectoryInfo(NonWindowsStorageProbePathVarTmp);

                // Initialize ApplicationfolderProvider
                var environmentVariables = new Hashtable
                {
                    { "TMPDIR", longDirectoryName },
                };

                var provider = new ApplicationFolderProvider(environmentVariables);

                IPlatformFolder applicationFolder = provider.GetApplicationFolder();

                // Evaluate
                Assert.IsNotNull(applicationFolder);
                Assert.IsFalse(Directory.Exists(longDirectoryName), "TEST ERROR: This directory should not be created.");
                Assert.IsTrue(Directory.Exists(varTmpdir.FullName), "TEST ERROR: This directory should be created.");
                Assert.IsTrue(varTmpdir.GetDirectories().Any(r => r.Name.Equals("Microsoft")), "TEST FAIL: TEMP subdirectories were not created");
                varTmpdir.EnumerateDirectories().ToList().ForEach(d => { if (d.Name == "Microsoft")
                                                                         {
                                                                             d.Delete(true);
                                                                         }
                                                                  });
            }
        }
Пример #5
0
        public void GetApplicationFolderReturnsValidPlatformFolder()
        {
            IApplicationFolderProvider provider          = new ApplicationFolderProvider();
            IPlatformFolder            applicationFolder = provider.GetApplicationFolder();

            Assert.IsNotNull(applicationFolder);
        }
        private static IPlatformFolder CreateAndValidateApplicationFolder(string rootPath, bool createSubFolder, IList <string> errors)
        {
            string          errorMessage = null;
            IPlatformFolder result       = null;

            try
            {
                if (!string.IsNullOrEmpty(rootPath))
                {
                    var telemetryDirectory = new DirectoryInfo(rootPath);
                    if (createSubFolder)
                    {
                        telemetryDirectory = CreateTelemetrySubdirectory(telemetryDirectory);
                    }

                    CheckAccessPermissions(telemetryDirectory);
                    TelemetryChannelEventSource.Log.StorageFolder(telemetryDirectory.FullName);

                    result = new PlatformFolder(telemetryDirectory);
                }
            }
            catch (UnauthorizedAccessException exp)
            {
                errorMessage = GetPathAccessFailureErrorMessage(exp, rootPath);
                TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedWarning(errorMessage);
            }
            catch (ArgumentException exp)
            {
                // Path does not specify a valid file path or contains invalid DirectoryInfo characters.
                errorMessage = GetPathAccessFailureErrorMessage(exp, rootPath);
                TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedWarning(errorMessage);
            }
            catch (DirectoryNotFoundException exp)
            {
                // The specified path is invalid, such as being on an unmapped drive.
                errorMessage = GetPathAccessFailureErrorMessage(exp, rootPath);
                TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedWarning(errorMessage);
            }
            catch (IOException exp)
            {
                // The subdirectory cannot be created. -or- A file or directory already has the name specified by path. -or-  The specified path, file name, or both exceed the system-defined maximum length. .
                errorMessage = GetPathAccessFailureErrorMessage(exp, rootPath);
                TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedWarning(errorMessage);
            }
            catch (SecurityException exp)
            {
                // The caller does not have code access permission to create the directory.
                errorMessage = GetPathAccessFailureErrorMessage(exp, rootPath);
                TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedWarning(errorMessage);
            }

            if (!string.IsNullOrEmpty(errorMessage))
            {
                errors.Add(errorMessage);
            }

            return(result);
        }
        public virtual void Initialize(IApplicationFolderProvider applicationFolderProvider)
        {
            if (applicationFolderProvider == null)
            {
                throw new ArgumentNullException("applicationFolderProvider");
            }

            this.folder = applicationFolderProvider.GetApplicationFolder();
        }
        public virtual void Initialize(IApplicationFolderProvider applicationFolderProvider)
        {
            if (applicationFolderProvider == null)
            {
                throw new ArgumentNullException(nameof(applicationFolderProvider));
            }

            this.folder = applicationFolderProvider.GetApplicationFolder();
        }
Пример #9
0
        /// <summary>
        /// private à la compil
        /// </summary>
        public void DebugTest()
        {
            DebugMode   = true;
            boxLog.Text = "Debug Mode";

            Platform = "Sega Mega Drive";

            // _CRelatLink = @"..\..\Games\Roms\Sega Mega Drive";

            AppPath = @"i:\Frontend\LaunchBox\";
            //PlatformFolder = @"..\..\Games\Roms\Sega Mega Drive";
            PlatformFolder = @".\Roms\Sega Mega Drive";


            IPlatformFolder[] raoul = new IPlatformFolder[15];

            MvFolder mvManuel = new MvFolder();

            mvManuel.FolderPath = @"..\..\Games\Manuels\Sega Mega Drive";
            mvManuel.MediaType  = "Manual";
            raoul[0]            = mvManuel;


            MvFolder mvMusic = new MvFolder();

            mvMusic.FolderPath = @"..\..\Games\Music\Sega Mega Drive";
            mvMusic.MediaType  = "Music";
            raoul[1]           = mvMusic;


            MvFolder mvVideo = new MvFolder();

            mvVideo.FolderPath = @"..\..\Games\Videos\Sega Mega Drive";
            mvVideo.MediaType  = "Video";
            raoul[2]           = mvVideo;

            for (int i = 3; i < 15; i += 3)
            {
                MvFolder mv3 = new MvFolder();
                mv3.FolderPath = @"..\..\Games\Covers\Sega Mega Drive\Steam Banner";
                mv3.MediaType  = "Banner";
                raoul[i]       = mv3;

                MvFolder ac = new MvFolder();
                ac.FolderPath = @"..\..\Games\Covers\Sega Mega Drive\Arcade - Cabinet";
                ac.MediaType  = "Arcade - Cabinet";
                raoul[i + 1]  = ac;

                MvFolder fbf = new MvFolder();
                fbf.FolderPath = @"..\..\Games\Covers\Sega Mega Drive\Fanart - Box - Front";
                fbf.MediaType  = "Fanart - Box - Front";
                raoul[i + 2]   = fbf;
            }

            _IPFolders = raoul;
        }
Пример #10
0
        public MvFolder(IPlatformFolder src, string LaunchBoxRoot)
        {
            Platform    = src.Platform;
            MediaType   = src.MediaType;
            FolderPath  = src.FolderPath;
            HFolderPath = Path.GetFullPath(Path.Combine(LaunchBoxRoot, FolderPath));

            //NewFolderPath = Languages.Lang.Waiting;
            //HNewFolderPath = Languages.Lang.Waiting;
        }
Пример #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="platformFolders"></param>
        /// <param name="categ"></param>
        /// <returns></returns>
        private C_PathsDouble?Get_PlatformFolder(IPlatformFolder ipl /*[] platformFolders*/, string categ)
        {
            //IPlatformFolder ipl = platformFolders.FirstOrDefault(x => x.MediaType.Equals(categ));

            if (ipl == null)
            {
                return(null);
            }

            return(new C_PathsDouble(ipl.FolderPath, ipl.MediaType));
        }
Пример #12
0
        internal static IPlatformFolder[] Get_PlatformPaths()
        {
            IPlatformFolder[] raoul = new IPlatformFolder[7];

            MvFolder mvManuel = new MvFolder();

            mvManuel.FolderPath = @"G:\Frontend\LaunchBox\Games\Manuels\Sega Mega Drive";
            mvManuel.MediaType  = "Manual";
            raoul[0]            = mvManuel;


            MvFolder mvMusic = new MvFolder();

            mvMusic.FolderPath = @"..\..\Games\Music\Sega Mega Drive";
            mvMusic.MediaType  = "Music";
            raoul[1]           = mvMusic;


            MvFolder mvVideo = new MvFolder();

            mvVideo.FolderPath = @"..\..\Games\Videos\Sega Mega Drive";
            mvVideo.MediaType  = "Video";
            raoul[2]           = mvVideo;

            // --- Images

            raoul[3] = new MvFolder()
            {
                MediaType  = "Banner",
                FolderPath = @"..\..\Games\Covers\Sega Mega Drive\Steam Banner"
            };

            raoul[4] = new MvFolder()
            {
                MediaType  = "Arcade - Cabinet",
                FolderPath = @"..\..\Games\Covers\Sega Mega Drive\Arcade - Cabinet"
            };

            raoul[5] = new MvFolder()
            {
                MediaType  = "Fanart - Box - Front",
                FolderPath = @"..\..\Games\Covers\Sega Mega Drive\Fanart - Box - Front"
            };

            raoul[6] = new MvFolder()
            {
                MediaType  = "Fanart - Card - Front",
                FolderPath = @"..\..\Games\Covers\Sega Mega Drive\Fanart - Card - Front",
            };

            return(raoul);
        }
        public TransmissionStorage(IApplicationFolderProvider applicationFolderProvider)
        {
            if (applicationFolderProvider == null)
            {
                throw new ArgumentNullException("applicationFolderProvider");
            }

            this.files = new ConcurrentQueue<IPlatformFile>();
            this.loadFilesLock = new object();
            this.sizeCalculated = false;

            this.folder = applicationFolderProvider.GetApplicationFolder();
        }
Пример #14
0
        public void GetApplicationFolderReturnsNullWhenNeitherLocalAppDataNorTempFolderIsAccessible()
        {
            var environmentVariables = new Hashtable
            {
                { "LOCALAPPDATA", this.CreateTestDirectory(@"AppData\Local", FileSystemRights.CreateDirectories, AccessControlType.Deny).FullName },
                { "TEMP", this.CreateTestDirectory("Temp", FileSystemRights.CreateDirectories, AccessControlType.Deny).FullName },
            };
            var provider = new ApplicationFolderProvider(environmentVariables);

            IPlatformFolder applicationFolder = provider.GetApplicationFolder();

            Assert.IsNull(applicationFolder);
        }
Пример #15
0
        public void GetApplicationFolderReturnsSubfolderFromTempFolderIfLocalAppDataIsNotAvailable()
        {
            DirectoryInfo temp = this.CreateTestDirectory("Temp");
            var           environmentVariables = new Hashtable {
                { "TEMP", temp.FullName }
            };
            var provider = new ApplicationFolderProvider(environmentVariables);

            IPlatformFolder applicationFolder = provider.GetApplicationFolder();

            Assert.IsNotNull(applicationFolder);
            Assert.AreEqual(1, temp.GetDirectories().Length);
        }
        public TransmissionStorage(IApplicationFolderProvider applicationFolderProvider)
        {
            if (applicationFolderProvider == null)
            {
                throw new ArgumentNullException("applicationFolderProvider");
            }

            this.files          = new ConcurrentQueue <IPlatformFile>();
            this.loadFilesLock  = new object();
            this.sizeCalculated = false;

            this.folder = applicationFolderProvider.GetApplicationFolder();
        }
Пример #17
0
        public void GetApplicationFolderReturnsSubfolderFromLocalAppDataFolder()
        {
            DirectoryInfo localAppData         = this.CreateTestDirectory(@"AppData\Local");
            var           environmentVariables = new Hashtable {
                { "LOCALAPPDATA", localAppData.FullName }
            };
            var provider = new ApplicationFolderProvider(environmentVariables);

            IPlatformFolder applicationFolder = provider.GetApplicationFolder();

            Assert.IsNotNull(applicationFolder);
            Assert.AreEqual(1, localAppData.GetDirectories().Length);
        }
Пример #18
0
 public static string GetBreadCrumb(IPlatformFolder folder)
 {
     var breadCrumb = string.Empty;
     if (folder != null)
     {
         var parentFolder = folder;
         do
         {
             breadCrumb = breadCrumb.Insert(0, parentFolder.Name + "/");
             parentFolder = parentFolder.Parent;
         } while (parentFolder != null);
     }
     return breadCrumb;
 }
Пример #19
0
        public void GetApplicationFolderReturnsNullWhenNoFolderAvailableToStoreDataInNonWindows()
        {
            if (!ApplicationFolderProvider.IsWindowsOperatingSystem())
            {
                var provider            = new ApplicationFolderProvider();
                var vartmpPathFieldInfo = provider.GetType().GetField("nonWindowsStorageProbePathVarTmp", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                vartmpPathFieldInfo.SetValue(provider, "");
                var tmpPathFieldInfo = provider.GetType().GetField("nonWindowsStorageProbePathTmp", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                tmpPathFieldInfo.SetValue(provider, "");

                IPlatformFolder applicationFolder = provider.GetApplicationFolder();
                Assert.IsNull(applicationFolder);
            }
        }
Пример #20
0
    private IPlatformFolder CreateAndValidateApplicationFolder(string path)
    {
        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        IPlatformFolder result             = null;
        var             telemetryDirectory = new DirectoryInfo(path);

        TelemetryChannelEventSource.Log.StorageFolder(telemetryDirectory.FullName);
        result = new PlatformFolder(telemetryDirectory);
        return(result);
    }
Пример #21
0
        public void GetApplicationFolderReturnsSubfolderFromTmpDirFolderInNonWindows()
        {
            if (!ApplicationFolderProvider.IsWindowsOperatingSystem())
            {
                DirectoryInfo tmpDir = this.testDirectory.CreateSubdirectory(@"tmpdir");
                var           environmentVariables = new Hashtable {
                    { "TMPDIR", tmpDir.FullName }
                };
                var provider = new ApplicationFolderProvider(environmentVariables);

                IPlatformFolder applicationFolder = provider.GetApplicationFolder();
                Assert.IsNotNull(applicationFolder);
                Assert.AreEqual(1, tmpDir.GetDirectories().Length);
                tmpDir.Delete(true);
            }
        }
Пример #22
0
        public void GetApplicationFolderReturnsSubfolderFromTempFolderIfLocalAppDataIsAvailableButNotAccessible()
        {
            DirectoryInfo localAppData         = this.CreateTestDirectory(@"AppData\Local", FileSystemRights.CreateDirectories, AccessControlType.Deny);
            DirectoryInfo temp                 = this.CreateTestDirectory("Temp");
            var           environmentVariables = new Hashtable
            {
                { "LOCALAPPDATA", localAppData.FullName },
                { "TEMP", temp.FullName },
            };
            var provider = new ApplicationFolderProvider(environmentVariables);

            IPlatformFolder applicationFolder = provider.GetApplicationFolder();

            Assert.IsNotNull(applicationFolder);
            Assert.AreEqual(1, temp.GetDirectories().Length);
        }
        public void GetApplicationFolderReturnsSubfolderFromTempFolderIfLocalAppDataIsUnmappedDrive()
        {
            DirectoryInfo temp = this.CreateTestDirectory("Temp");
            var           environmentVariables = new Hashtable
            {
                { "LOCALAPPDATA", @"L:\Temp" },
                { "TEMP", temp.FullName },
            };
            var provider = new ApplicationFolderProvider(environmentVariables);

            IPlatformFolder applicationFolder = provider.GetApplicationFolder();

            Assert.IsNotNull(applicationFolder);
            Assert.AreEqual(1, temp.GetDirectories().Length);

            temp.Delete(true);
        }
        public void GetApplicationFolderReturnsNullWhenUnableToSetSecurityPolicyOnDirectory()
        {
            var environmentVariables = new Hashtable
            {
                { "LOCALAPPDATA", this.CreateTestDirectory(@"AppData\Local").FullName },
                { "TEMP", this.CreateTestDirectory("Temp").FullName },
            };

            var provider = new ApplicationFolderProvider(environmentVariables);

            // Override to return false indicating applying security failed.
            provider.OverrideApplySecurityToDirectory((dirInfo) => { return(false); });

            IPlatformFolder applicationFolder = provider.GetApplicationFolder();

            Assert.IsNull(applicationFolder);
        }
        public void GetApplicationFolderReturnsSubfolderFromCustomFolderFirst()
        {
            DirectoryInfo localAppData = this.CreateTestDirectory(@"AppData\Local");
            DirectoryInfo customFolder = this.CreateTestDirectory(@"Custom");

            var environmentVariables = new Hashtable {
                { "LOCALAPPDATA", localAppData.FullName }
            };
            var provider = new ApplicationFolderProvider(environmentVariables, customFolder.FullName);

            IPlatformFolder applicationFolder = provider.GetApplicationFolder();

            Assert.IsNotNull(applicationFolder);
            Assert.AreEqual(((PlatformFolder)applicationFolder).Folder.Name, customFolder.Name, "Sub-folder for custom folder should not be created.");

            localAppData.Delete(true);
            customFolder.Delete(true);
        }
Пример #26
0
        public void GetApplicationFolderReturnsSubfolderFromVarTmpFolderIfTmpDirIsNotAvailableInNonWindows()
        {
            if (!ApplicationFolderProvider.IsWindowsOperatingSystem())
            {
                var dir      = new System.IO.DirectoryInfo(NonWindowsStorageProbePathVarTmp);
                var provider = new ApplicationFolderProvider();

                IPlatformFolder applicationFolder = provider.GetApplicationFolder();

                Assert.IsNotNull(applicationFolder);
                Assert.IsTrue(dir.GetDirectories().Any(r => r.Name.Equals("Microsoft")));


                dir.EnumerateDirectories().ToList().ForEach(d => { if (d.Name == "Microsoft")
                                                                   {
                                                                       d.Delete(true);
                                                                   }
                                                            });
            }
        }
Пример #27
0
        public void GetApplicationFolderReturnsCustomFolderWhenConfiguredAndExists()
        {
            DirectoryInfo localAppData = this.CreateTestDirectory(@"AppData\Local");
            DirectoryInfo customFolder = this.CreateTestDirectory(@"Custom");

            try
            {
                var environmentVariables = new Hashtable {
                    { "LOCALAPPDATA", localAppData.FullName }
                };
                var             provider          = new ApplicationFolderProvider(environmentVariables, customFolder.FullName);
                IPlatformFolder applicationFolder = provider.GetApplicationFolder();
                Assert.IsNotNull(applicationFolder);
                Assert.AreEqual(customFolder.Name, ((PlatformFolder)applicationFolder).Folder.Name, "Configured custom folder should be used when available.");
            }
            finally
            {
                DeleteIfExists(localAppData);
                DeleteIfExists(customFolder);
            }
        }
        public void GetApplicationFolderReturnsSubfolderFromTempFolderIfLocalAppDataIsTooLong()
        {
            string longName = new string('A', 238 - this.testDirectory.FullName.Length);

            DirectoryInfo localAppData         = this.CreateTestDirectory(longName);
            DirectoryInfo temp                 = this.CreateTestDirectory("Temp");
            var           environmentVariables = new Hashtable
            {
                { "LOCALAPPDATA", localAppData.FullName },
                { "TEMP", temp.FullName },
            };
            var provider = new ApplicationFolderProvider(environmentVariables);

            IPlatformFolder applicationFolder = provider.GetApplicationFolder();

            Assert.IsNotNull(applicationFolder);
            Assert.AreEqual(1, temp.GetDirectories().Length);

            localAppData.Delete(true);
            temp.Delete(true);
        }
Пример #29
0
        public void GetApplicationFolderReturnsSubfolderFromCustomFolderFirstInNonWindows()
        {
            if (!ApplicationFolderProvider.IsWindowsOperatingSystem())
            {
                DirectoryInfo tmpDir       = this.testDirectory.CreateSubdirectory(@"tmpdir");
                DirectoryInfo customFolder = this.testDirectory.CreateSubdirectory(@"Custom");

                var environmentVariables = new Hashtable {
                    { "TMPDIR", tmpDir.FullName }
                };
                var provider = new ApplicationFolderProvider(environmentVariables, customFolder.FullName);

                IPlatformFolder applicationFolder = provider.GetApplicationFolder();

                Assert.IsNotNull(applicationFolder);
                Assert.AreEqual(((PlatformFolder)applicationFolder).Folder.Name, customFolder.Name, "Sub-folder for custom folder should not be created.");

                tmpDir.Delete(true);
                customFolder.Delete(true);
            }
        }
Пример #30
0
        /// <summary>
        /// Initialise les folders en fonction dun tableau des platformFolders
        /// </summary>
        /// <param name="platformFolders"></param>
        private void BuildCategsFolders(IPlatformFolder[] platformFolders)
        {
            //
            for (int i = 0; i < platformFolders.Length; i++)

            {
                // 12/2020 il y avait une boucle inutile
                IPlatformFolder p = platformFolders[i];
                switch (p.MediaType)
                {
                case "Manual":
                    this.ManuelPath = Get_PlatformFolder(p /*platformFolders*/, "Manual");
                    break;

                case "Music":
                    this.MusicPath = Get_PlatformFolder(p /*latformFolders*/, "Music");
                    break;

                case "Video":
                    this.VideoPath = Get_PlatformFolder(p /*latformFolders*/, "Video");
                    break;

                case "Theme Video":
                    this.ThemeVideoPath = Get_PlatformFolder(p, "Theme Video");
                    break;

                default:
                    //C_PathsCollec tmp = new C_PathsCollec(p);
                    C_PathsDouble tmp = Get_PlatformFolder(p /*latformFolders*/, p.MediaType);
                    if (tmp.Type.Length > LongestCateg)
                    {
                        LongestCateg = tmp.Type.Length;
                    }
                    //            ExtPlatformPaths.Add(tmp);
                    this.AddImagePaths(tmp);

                    break;
                }
            }
        }
Пример #31
0
        public PlatformFolder(IPlatformSession session, IPlatformUser user, IPlatformFolder parentFolder, JToken content)
            : base(session, user)
        {
            Contract.Requires(session != null);
            Contract.Requires(user != null);
            Contract.Requires(content != null);

            Parent = parentFolder;
            Id = content.SelectToken("id").Value<long>();
            Name = content.SelectToken("name").Value<string>();
            Description = content.SelectToken("description").Value<string>();
            FileCount = content.SelectToken("file_counter").Value<long>();
            FolderCount = content.SelectToken("folder_counter").Value<long>();
            MemberCount = content.SelectToken("members_counter").Value<long>();
            ParentId = content.SelectToken("parent_id").Value<long?>();
            Url = content.SelectToken("url").Value<string>();
            Uuid = content.SelectToken("uuid").Value<string>();

            Owner = new PlatformUser(session, content.SelectToken("owner"));
            Permissions = new PlatformPermissions(content, content.SelectToken("permissions"));
            IsOwner = user.Email == Owner.Email;
        }
Пример #32
0
        public void GetApplicationFolderReturnsSubfolderFromTmpFolderIfVarTmpIsNotAvailableInNonWindows()
        {
            if (!ApplicationFolderProvider.IsWindowsOperatingSystem())
            {
                var dir = new System.IO.DirectoryInfo(NonWindowsStorageProbePathTmp);

                var provider            = new ApplicationFolderProvider();
                var vartmpPathFieldInfo = provider.GetType().GetField("nonWindowsStorageProbePathVarTmp", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                vartmpPathFieldInfo.SetValue(provider, "");

                IPlatformFolder applicationFolder = provider.GetApplicationFolder();

                Assert.IsNotNull(applicationFolder);
                Assert.IsTrue(dir.GetDirectories().Any(r => r.Name.Equals("Microsoft")));


                dir.EnumerateDirectories().ToList().ForEach(d => { if (d.Name == "Microsoft")
                                                                   {
                                                                       d.Delete(true);
                                                                   }
                                                            });
            }
        }
        public void GetApplicationFolderReturnsSubfolderFromTempFolderIfLocalAppDataIsTooLong()
        {
            // For reasons i don't understand, DotNetCore is able to create longer directory names. I've increased the length of this test path to guarantee that it fails.
            string        longDirectoryName = Path.Combine(this.testDirectory.FullName, new string('A', 300)); //Windows has a max directory length of 248 characters.
            DirectoryInfo temp = this.CreateTestDirectory("Temp");

            // Initialize ApplicationfolderProvider
            var environmentVariables = new Hashtable
            {
                { "LOCALAPPDATA", longDirectoryName },
                { "TEMP", temp.FullName },
            };
            var             provider          = new ApplicationFolderProvider(environmentVariables);
            IPlatformFolder applicationFolder = provider.GetApplicationFolder();

            // Evaluate
            Assert.IsNotNull(applicationFolder);
            Assert.IsFalse(Directory.Exists(longDirectoryName), "TEST ERROR: This directory should not be created.");
            Assert.IsTrue(Directory.Exists(temp.FullName), "TEST ERROR: This directory should be created.");
            Assert.AreEqual(1, temp.GetDirectories().Length, "TEST FAIL: TEMP subdirectories were not created");

            temp.Delete(true);
        }
Пример #34
0
        public int GetFileFormatIndex(string path, string sFormats)
        {

            if (System.Windows.Application.Current == null)
                new System.Windows.Application { ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown };

            var context = /*SynchronizationContext.Current ??*/ new WindowsFormsSynchronizationContext();
            string fileFormatByDefault = "Portable Document Format (*.pdf)";

            try
            {
                WorkshareOnline.Instance.Security.Authenticate(context);

                var fileFormats = ParseFormats(sFormats);
                var window = new FileSaveWindow(path, fileFormats);

                if (fileFormats.Contains(fileFormatByDefault))
                {
                    window.SelectedFileFormatIndex = fileFormats.FindIndex(x => x.Equals(fileFormatByDefault, StringComparison.InvariantCultureIgnoreCase));
                }
                
                new System.Windows.Interop.WindowInteropHelper(window).Owner = Process.GetCurrentProcess().MainWindowHandle;

                if (window.ShowDialog() == true)
                {
                    platformFolder = (IPlatformFolder)window.SelectedEntity;
                    fileName = window.FileName;
                    return window.SelectedFileFormatIndex;
                }
            }
            catch (OperationCanceledException)
            {
                // ignore the user has cancelled
            }
            catch (UnauthorizedAccessException e)
            {
                Workshare.Interop.Messaging.WsMessage.ShowMessage(IntPtr.Zero,
                    e.Message, Workshare.Interop.Messaging.MessageButtons.WsOK,
                    Workshare.Interop.Messaging.MessageBranding.WsDefault,
                    Workshare.Interop.Messaging.MessageType.WsErrorIcon, "",
                    0);
            }
            catch (Exception e)
            {
                var message = e.InnerException == null ? e.Message : e.InnerException.Message;

                Workshare.Interop.Messaging.WsMessage.ShowMessage(IntPtr.Zero,
                    "Error saving to Workshare: \n\n" + message, Workshare.Interop.Messaging.MessageButtons.WsOK,
                    Workshare.Interop.Messaging.MessageBranding.WsDefault,
                    Workshare.Interop.Messaging.MessageType.WsErrorIcon, "",
                    0);
            }

            return -1;
        }
Пример #35
0
        private JToken CreateVersion(string fileName, string displayName, IPlatformFolder folder, bool isChunking, int fileId = -1)
        {
            using (var handler = new HttpClientHandler() { CookieContainer = Session.Cookies })
            using (var client = new HttpClient(handler) { BaseAddress = Host.Uri })
            {
                client.DefaultRequestHeaders.Add("User-Agent", "WorkshareProtect");

                var parameters = new List<KeyValuePair<string, string>>()
                                 {
                                    new KeyValuePair<string, string>("use_proxy", "true"),
                                    new KeyValuePair<string, string>("file_version[binary_file_file_name]", Path.GetFileName(fileName)),
                                 };
                if (folder != null)
                {
                    if (string.IsNullOrEmpty(folder.Uuid))
	                {
	                    parameters.Add(new KeyValuePair<string, string>("file_version[folder_id]", folder.Id.ToString(CultureInfo.InvariantCulture)));
	                }
	                else
	                {
	                    parameters.Add(new KeyValuePair<string, string>("file_version[folder_uuid]", folder.Uuid.ToString(CultureInfo.InvariantCulture)));
	                }
                }
                if (!string.IsNullOrEmpty(displayName))
                {
                    parameters.Add(new KeyValuePair<string, string>("file_version[name]", displayName));
                }
                if (fileId > 0)
                {
                    parameters.Add(new KeyValuePair<string, string>("file_version[file_id]", fileId.ToString()));
                }
                if (!isChunking)
                {
                    parameters.Add(new KeyValuePair<string, string>("file_version[complete_file_provide_upload_info]", "true"));   
                }

                var url = fileId > 0
                    ? string.Format("/api/v1.2/files/{0}/file_versions.json", fileId)
                    : string.Format("/api/v1.2/file_versions.json");

                var response = client.PostAsync(url, new FormUrlEncodedContent(parameters)).Result;
                response.EnsureSuccessStatusCode();

                var content = response.Content.ReadAsStringAsync().Result;

                return JObject.Parse(content);
            }
        }
 public ExtPlatformFolder(IPlatformFolder ipf)
 {
     this.MediaType  = ipf.MediaType;
     this.FolderPath = Path.GetFullPath(ipf.FolderPath);//Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ipf.FolderPath);
     this.Platform   = ipf.Platform;
 }