Ejemplo n.º 1
0
        private bool CheckStorageLocationPath()
        {
            bool settingsOk = Directory.Exists(FilenameHelper.FillVariables(textbox_storagelocation.Text, false));

            DisplayTextBoxValidity(textbox_storagelocation, settingsOk);
            return(settingsOk);
        }
Ejemplo n.º 2
0
        private DocumentMetadata GetDocumentMetadata(string filename)
        {
            Logger.LogMessage($"Get document metadata for '{filename}'");

            DocumentMetadata documentMetadata = null;
            var filenameHelper = new FilenameHelper();
            var hasId          = filenameHelper.HasId(filename);
            var id             = 0;

            if (hasId)
            {
                id = int.Parse(filenameHelper.GetId(filename));
            }

            foreach (var metadataEntry in metadata)
            {
                if ((hasId && id == metadataEntry.DocumentId) ||
                    (metadataEntry.DocumentFilename.Equals(filename, StringComparison.InvariantCultureIgnoreCase)))
                {
                    documentMetadata = metadataEntry;
                    break;
                }
            }

            return(documentMetadata);
        }
Ejemplo n.º 3
0
        public bool Upload(ICaptureDetails captureDetails, ISurface surface, out string uploadUrl)
        {
            SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, false);

            uploadUrl = null;
            try {
                string flickrUrl = null;
                new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("flickr", LangKey.communication_wait),
                                                 delegate {
                    string filename = Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
                    flickrUrl       = FlickrUtils.UploadToFlickr(surface, outputSettings, captureDetails.Title, filename);
                }
                                                 );

                if (flickrUrl == null)
                {
                    return(false);
                }
                uploadUrl = flickrUrl;

                if (_config.AfterUploadLinkToClipBoard)
                {
                    ClipboardHelper.SetClipboardData(flickrUrl);
                }
                return(true);
            } catch (Exception e) {
                Log.Error("Error uploading.", e);
                MessageBox.Show(Language.GetString("flickr", LangKey.upload_failure) + " " + e.Message);
            }
            return(false);
        }
        private string GetRootDirFromConfig()
        {
            string rootDir = conf.OutputFilePath;

            rootDir = FilenameHelper.FillVariables(rootDir, false);
            return(rootDir);
        }
Ejemplo n.º 5
0
        private void DisplaySettings()
        {
            colorButton_window_background.SelectedColor = coreConfiguration.DWMBackgroundColor;

            if (Language.CurrentLanguage != null)
            {
                combobox_language.SelectedValue = Language.CurrentLanguage;
            }
            // Disable editing when the value is fixed
            combobox_language.Enabled = !coreConfiguration.Values["Language"].IsFixed;

            textbox_storagelocation.Text = FilenameHelper.FillVariables(coreConfiguration.OutputFilePath, false);
            // Disable editing when the value is fixed
            textbox_storagelocation.Enabled = !coreConfiguration.Values["OutputFilePath"].IsFixed;

            SetWindowCaptureMode(coreConfiguration.WindowCaptureMode);
            // Disable editing when the value is fixed
            combobox_window_capture_mode.Enabled = !coreConfiguration.CaptureWindowsInteractive && !coreConfiguration.Values["WindowCaptureMode"].IsFixed;
            radiobuttonWindowCapture.Checked     = !coreConfiguration.CaptureWindowsInteractive;

            trackBarJpegQuality.Value   = coreConfiguration.OutputFileJpegQuality;
            trackBarJpegQuality.Enabled = !coreConfiguration.Values["OutputFileJpegQuality"].IsFixed;
            textBoxJpegQuality.Text     = coreConfiguration.OutputFileJpegQuality + "%";

            DisplayDestinations();

            numericUpDownWaitTime.Value   = coreConfiguration.CaptureDelay >= 0?coreConfiguration.CaptureDelay:0;
            numericUpDownWaitTime.Enabled = !coreConfiguration.Values["CaptureDelay"].IsFixed;
            if (IniConfig.IsPortable)
            {
                checkbox_autostartshortcut.Visible = false;
                checkbox_autostartshortcut.Checked = false;
            }
            else
            {
                // Autostart checkbox logic.
                if (StartupHelper.hasRunAll())
                {
                    // Remove runUser if we already have a run under all
                    StartupHelper.deleteRunUser();
                    checkbox_autostartshortcut.Enabled = StartupHelper.canWriteRunAll();
                    checkbox_autostartshortcut.Checked = true;                     // We already checked this
                }
                else if (StartupHelper.IsInStartupFolder())
                {
                    checkbox_autostartshortcut.Enabled = false;
                    checkbox_autostartshortcut.Checked = true;                     // We already checked this
                }
                else
                {
                    // No run for all, enable the checkbox and set it to true if the current user has a key
                    checkbox_autostartshortcut.Enabled = StartupHelper.canWriteRunUser();
                    checkbox_autostartshortcut.Checked = StartupHelper.hasRunUser();
                }
            }

            numericUpDown_daysbetweencheck.Value   = coreConfiguration.UpdateCheckInterval;
            numericUpDown_daysbetweencheck.Enabled = !coreConfiguration.Values["UpdateCheckInterval"].IsFixed;
            CheckDestinationSettings();
        }
Ejemplo n.º 6
0
        public SessionRecordingPathsBuilder(string path, SessionRecording session)
        {
            string sessionFolder = FilenameHelper.ReplaceInvalidFileNameChars(session.Id);
            var    rootPath      = Path.Combine(path, sessionFolder);

            _rootDirectory = new DirectoryInfo(rootPath.TrimEnd());
        }
Ejemplo n.º 7
0
        public void Upload(ICaptureDetails captureDetails, ISurface surface, ExportInformation exportInformation)
        {
            SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, false);

            try {
                string flickrUrl = null;
                new PleaseWaitForm().ShowAndWait("Flickr plug-in", Language.GetString("flickr", LangKey.communication_wait),
                                                 delegate() {
                    string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
                    flickrUrl       = FlickrUtils.UploadToFlickr(surface, outputSettings, captureDetails.Title, filename);
                }
                                                 );

                if (flickrUrl == null)
                {
                    exportInformation.ExportMade = false;
                    return;
                }
                exportInformation.ExportMade = true;
                exportInformation.Uri        = flickrUrl;

                if (config.AfterUploadLinkToClipBoard)
                {
                    ClipboardHelper.SetClipboardData(flickrUrl);
                }
            } catch (Exception e) {
                MessageBox.Show(Language.GetString("flickr", LangKey.upload_failure) + " " + e.Message);
            }
        }
Ejemplo n.º 8
0
        private string CreateNewFilename(ICaptureDetails captureDetails)
        {
            string fullPath = null;

            Log.Info().WriteLine("Creating new filename");

            CoreConfiguration.ValidateAndCorrect();

            var filename = FilenameHelper.GetFilenameFromPattern(CoreConfiguration.OutputFileFilenamePattern, CoreConfiguration.OutputFileFormat, captureDetails);
            var filepath = FilenameHelper.FillVariables(CoreConfiguration.OutputFilePath, false);

            try
            {
                fullPath = Path.Combine(filepath, filename);
            }
            catch (ArgumentException)
            {
                // configured filename or path not valid, show error message...
                Log.Info().WriteLine("Generated path or filename not valid: {0}, {1}", filepath, filename);

                MessageBox.Show(GreenshotLanguage.ErrorSaveInvalidChars, GreenshotLanguage.Error);
                // TODO: offer settings?
                // ... lets get the pattern fixed....
                //	fullPath = CreateNewFilename(captureDetails);
                // ... cancelled.
                // fullPath = null;
            }
            return(fullPath);
        }
Ejemplo n.º 9
0
        private void DisplaySettings()
        {
            colorButton_window_background.SelectedColor = coreConfiguration.DWMBackgroundColor;

            if (Language.CurrentLanguage != null)
            {
                combobox_language.SelectedValue = Language.CurrentLanguage;
            }
            textbox_storagelocation.Text = FilenameHelper.FillVariables(coreConfiguration.OutputFilePath, false);

            SetWindowCaptureMode(coreConfiguration.WindowCaptureMode);

            trackBarJpegQuality.Value = coreConfiguration.OutputFileJpegQuality;
            textBoxJpegQuality.Text   = coreConfiguration.OutputFileJpegQuality + "%";

            DisplayDestinations();

            numericUpDownWaitTime.Value = coreConfiguration.CaptureDelay >= 0 ? coreConfiguration.CaptureDelay : 0;

            // If the run for all is set we disable and set the checkbox
            if (StartupHelper.checkRunAll())
            {
                checkbox_autostartshortcut.Enabled = false;
                checkbox_autostartshortcut.Checked = true;
            }
            else
            {
                // No run for all, enable the checkbox and set it to true if the current user has a key
                checkbox_autostartshortcut.Enabled = true;
                checkbox_autostartshortcut.Checked = StartupHelper.checkRunUser();
            }

            numericUpDown_daysbetweencheck.Value = coreConfiguration.UpdateCheckInterval;
            CheckDestinationSettings();
        }
Ejemplo n.º 10
0
        /// <summary>
        ///     Check and eventually fix the command settings
        /// </summary>
        /// <param name="command"></param>
        /// <returns>false if the command is not correctly configured</returns>
        private bool IsCommandValid(string command)
        {
            if (!_externalCommandConfig.RunInbackground.ContainsKey(command))
            {
                Log.Warn().WriteLine("Found missing runInbackground for {0}", command);
                // Fix it
                _externalCommandConfig.RunInbackground.Add(command, true);
            }
            if (!_externalCommandConfig.Argument.ContainsKey(command))
            {
                Log.Warn().WriteLine("Found missing argument for {0}", command);
                // Fix it
                _externalCommandConfig.Argument.Add(command, "{0}");
            }
            if (!_externalCommandConfig.Commandline.ContainsKey(command))
            {
                Log.Warn().WriteLine("Found missing commandline for {0}", command);
                return(false);
            }
            var commandline = FilenameHelper.FillVariables(_externalCommandConfig.Commandline[command], true);

            commandline = FilenameHelper.FillCmdVariables(commandline, true);

            if (File.Exists(commandline))
            {
                return(true);
            }
            Log.Warn().WriteLine("Found 'invalid' commandline {0} for command {1}", _externalCommandConfig.Commandline[command], command);
            return(false);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// The Contextmenu_OpenRecent currently opens the last know save location
        /// </summary>
        private void Contextmenu_OpenRecent(object sender, EventArgs eventArgs)
        {
            string path;
            string configPath   = FilenameHelper.FillVariables(conf.OutputFilePath, false);
            string lastFilePath = Path.GetDirectoryName(conf.OutputFileAsFullpath);

            if (Directory.Exists(lastFilePath))
            {
                path = lastFilePath;
            }
            else if (Directory.Exists(configPath))
            {
                path = configPath;
            }
            else
            {
                // What do I open when nothing can be found? Right, nothing...
                return;
            }
            LOG.Debug("DoubleClick was called! Starting: " + path);
            try
            {
                System.Diagnostics.Process.Start(path);
            }
            catch (Exception e)
            {
                // Make sure we show what we tried to open in the exception
                e.Data.Add("path", path);
                throw e;
            }
        }
Ejemplo n.º 12
0
        private string UpdateFilenameWithPostId(string documentFilename, int documentId)
        {
            string newFilename    = null;
            var    filenameHelper = new FilenameHelper();

            if (filenameHelper.HasId(documentFilename))
            {
                // We have an ID so let's see what it is
                var id = int.Parse(filenameHelper.GetId(documentFilename));

                if (id != documentId)
                {
                    // ID has been set but does not match the current ID in the filename so let's change it
                    newFilename = filenameHelper.SetId(documentFilename, documentId.ToString());
                }
            }
            else
            {
                // The filename does not currently contain an ID so let's set it
                newFilename = filenameHelper.SetId(documentFilename, documentId.ToString());
            }

            // Now let's rename the file in version control
            if (newFilename == null)
            {
                return(documentFilename);
            }

            vstsHelper.RenameFile(vstsAuthentication, project, repoName, branch, documentFilename, newFilename, "Renaming file to include Post ID. ***NO_CI***");

            return(newFilename);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// This will be called when the menu item in the Editor is clicked
        /// </summary>
        public string Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload)
        {
            SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, false);

            try {
                string           url           = null;
                string           filename      = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
                SurfaceContainer imageToUpload = new SurfaceContainer(surfaceToUpload, outputSettings, filename);

                new PleaseWaitForm().ShowAndWait("Box plug-in", Language.GetString("box", LangKey.communication_wait),
                                                 delegate() {
                    url = BoxUtils.UploadToBox(imageToUpload, captureDetails.Title, filename);
                }
                                                 );

                if (url != null && config.AfterUploadLinkToClipBoard)
                {
                    ClipboardHelper.SetClipboardData(url);
                }

                return(url);
            } catch (Exception ex) {
                LOG.Error("Error uploading.", ex);
                MessageBox.Show(Language.GetString("box", LangKey.upload_failure) + " " + ex.ToString());
                return(null);
            }
        }
Ejemplo n.º 14
0
        public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, out string uploadUrl)
        {
            SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality);

            try {
                string url = null;
                new PleaseWaitForm().ShowAndWait("Picasa plug-in", Language.GetString("picasa", LangKey.communication_wait),
                                                 delegate() {
                    string filename    = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
                    string contentType = "image/" + config.UploadFormat.ToString();
                    url = PicasaUtils.UploadToPicasa(surfaceToUpload, outputSettings, captureDetails.Title, filename);
                }
                                                 );
                uploadUrl = url;

                if (uploadUrl != null && config.AfterUploadLinkToClipBoard)
                {
                    ClipboardHelper.SetClipboardData(uploadUrl);
                }
                return(true);
            } catch (Exception e) {
                MessageBox.Show(Language.GetString("picasa", LangKey.upload_failure) + " " + e.ToString());
            }
            uploadUrl = null;
            return(false);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Upload the capture to imgur
        /// </summary>
        /// <param name="captureDetails">ICaptureDetails</param>
        /// <param name="surfaceToUpload">ISurface</param>
        /// <param name="uploadUrl">out string for the url</param>
        /// <returns>true if the upload succeeded</returns>
        public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, out string uploadUrl)
        {
            SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, _config.UploadReduceColors);

            try {
                string    filename  = Path.GetFileName(FilenameHelper.GetFilenameFromPattern(_config.FilenamePattern, _config.UploadFormat, captureDetails));
                ImgurInfo imgurInfo = null;

                // Run upload in the background
                new PleaseWaitForm().ShowAndWait("Imgur plug-in", Language.GetString("imgur", LangKey.communication_wait),
                                                 delegate
                {
                    imgurInfo = ImgurUtils.UploadToImgur(surfaceToUpload, outputSettings, captureDetails.Title, filename);
                    if (imgurInfo != null && _config.AnonymousAccess)
                    {
                        Log.InfoFormat("Storing imgur upload for hash {0} and delete hash {1}", imgurInfo.Hash, imgurInfo.DeleteHash);
                        _config.ImgurUploadHistory.Add(imgurInfo.Hash, imgurInfo.DeleteHash);
                        _config.runtimeImgurHistory.Add(imgurInfo.Hash, imgurInfo);
                        CheckHistory();
                    }
                }
                                                 );

                if (imgurInfo != null)
                {
                    // TODO: Optimize a second call for export
                    using (Image tmpImage = surfaceToUpload.GetImageForExport()) {
                        imgurInfo.Image = ImageHelper.CreateThumbnail(tmpImage, 90, 90);
                    }
                    IniConfig.Save();

                    if (_config.UsePageLink)
                    {
                        uploadUrl = imgurInfo.Page;
                    }
                    else
                    {
                        uploadUrl = imgurInfo.Original;
                    }
                    if (!string.IsNullOrEmpty(uploadUrl) && _config.CopyLinkToClipboard)
                    {
                        try
                        {
                            ClipboardHelper.SetClipboardData(uploadUrl);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Can't write to clipboard: ", ex);
                            uploadUrl = null;
                        }
                    }
                    return(true);
                }
            } catch (Exception e) {
                Log.Error("Error uploading.", e);
                MessageBox.Show(Language.GetString("imgur", LangKey.upload_failure) + " " + e.Message);
            }
            uploadUrl = null;
            return(false);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// This will be called when the menu item in the Editor is clicked
        /// </summary>
        public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, out string uploadUrl)
        {
            uploadUrl = null;
            SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, false);

            try {
                string dropboxUrl = null;
                new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("dropbox", LangKey.communication_wait),
                                                 delegate() {
                    string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
                    dropboxUrl      = DropboxUtils.UploadToDropbox(surfaceToUpload, outputSettings, filename);
                }
                                                 );
                if (dropboxUrl == null)
                {
                    return(false);
                }
                uploadUrl = dropboxUrl;
                return(true);
            } catch (Exception e) {
                LOG.Error(e);
                MessageBox.Show(Language.GetString("dropbox", LangKey.upload_failure) + " " + e.Message);
                return(false);
            }
        }
Ejemplo n.º 17
0
        private string GetFilesystemPath(INote note)
        {
            var filename = FilenameHelper.ConvertStringForFilename(note.Title);

            if (string.IsNullOrWhiteSpace(filename))
            {
                filename = FilenameHelper.ConvertStringForFilename(note.UniqueName);
            }

            var ext = ".txt";

            if (note.HasTagCaseInsensitive(AppSettings.TAG_MARKDOWN))
            {
                ext = ".md";
            }

            if (note.Path.IsRoot())
            {
                return(Path.Combine(_path, filename + ext));
            }

            var comp = new[] { _path }
            .Concat(note.Path.Enumerate().Select(FilenameHelper.ConvertStringForFilename))
            .Concat(new[] { filename + ext });

            return(Path.Combine(comp.ToArray()));
        }
Ejemplo n.º 18
0
        private IEnumerable <PathEntry> EnumerateFolder(DirectoryPath dsrcpath, string fsrcpath, int depth)
        {
            if (depth >= _searchDepth)
            {
                yield break;
            }

            foreach (var filepath in Directory.EnumerateFiles(fsrcpath))
            {
                if (!filepath.ToLower().EndsWith(".txt") && !filepath.ToLower().EndsWith(".md"))
                {
                    continue;
                }

                yield return(new PathEntry(
                                 filepath,
                                 dsrcpath,
                                 FilenameHelper.ConvertStringFromFilenameBack(Path.GetFileNameWithoutExtension(filepath)),
                                 new DateTimeOffset(new FileInfo(filepath).LastWriteTime),
                                 File.ReadAllText(filepath, _encoding)));
            }

            foreach (var dir in Directory.EnumerateDirectories(fsrcpath))
            {
                var d = dsrcpath.SubDir(FilenameHelper.ConvertStringFromFilenameBack(Path.GetFileName(dir)));

                foreach (var item in EnumerateFolder(d, dir, depth + 1))
                {
                    yield return(item);
                }
            }
        }
Ejemplo n.º 19
0
        public void FilenameDoesNotHaveIdTest()
        {
            var filenameHelper = new FilenameHelper();
            var filename       = "My Markdown File.md";
            var result         = filenameHelper.HasId(filename);

            Assert.IsFalse(result);
        }
Ejemplo n.º 20
0
        public void GetFilenameWithoutIdTest()
        {
            var filenameHelper = new FilenameHelper();
            var filename       = "My Markdown File[_1021].md";
            var result         = filenameHelper.GetFilenameWithoutId(filename);

            Assert.AreEqual("My Markdown File.md", result);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// sets InitialDirectory and FileName property of a SaveFileDialog smartly, considering default pattern and last used path
        /// </summary>
        /// <param name="sfd">a SaveFileDialog instance</param>
        private void ApplySuggestedValues()
        {
            // build the full path and set dialog properties
            string filenameFromPattern = FilenameHelper.GetFilenameWithoutExtensionFromPattern(conf.OutputFileFilenamePattern, captureDetails);

            FileName  = Path.GetFileNameWithoutExtension(filenameFromPattern);
            Extension = Path.GetExtension(filenameFromPattern);
        }
Ejemplo n.º 22
0
        public void FilenameHasIdTest()
        {
            var filenameHelper = new FilenameHelper();
            var filename       = "My Markdown File[_1021 ].md";
            var result         = filenameHelper.HasId(filename);

            Assert.IsTrue(result);
        }
Ejemplo n.º 23
0
        /// <summary>
        ///     The actual executing code for the external command
        /// </summary>
        /// <param name="commando"></param>
        /// <param name="fullPath"></param>
        /// <param name="verb"></param>
        /// <param name="output"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        private static int CallExternalCommand(string commando, string fullPath, string verb, out string output, out string error)
        {
            var commandline = Config.Commandline[commando];
            var arguments   = Config.Argument[commando];

            output = null;
            error  = null;
            if (!string.IsNullOrEmpty(commandline))
            {
                using (var process = new Process())
                {
                    // Fix variables
                    commandline = FilenameHelper.FillVariables(commandline, true);
                    commandline = FilenameHelper.FillCmdVariables(commandline);

                    arguments = FilenameHelper.FillVariables(arguments, false);
                    arguments = FilenameHelper.FillCmdVariables(arguments, false);

                    process.StartInfo.FileName        = FilenameHelper.FillCmdVariables(commandline);
                    process.StartInfo.Arguments       = FormatArguments(arguments, fullPath);
                    process.StartInfo.UseShellExecute = false;
                    if (Config.RedirectStandardOutput)
                    {
                        process.StartInfo.RedirectStandardOutput = true;
                    }
                    if (Config.RedirectStandardError)
                    {
                        process.StartInfo.RedirectStandardError = true;
                    }
                    if (verb != null)
                    {
                        process.StartInfo.Verb = verb;
                    }
                    Log.Info().WriteLine("Starting : {0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
                    process.Start();
                    process.WaitForExit();
                    if (Config.RedirectStandardOutput)
                    {
                        output = process.StandardOutput.ReadToEnd();
                        if (Config.ShowStandardOutputInLog && output.Trim().Length > 0)
                        {
                            Log.Info().WriteLine("Output:\n{0}", output);
                        }
                    }
                    if (Config.RedirectStandardError)
                    {
                        error = process.StandardError.ReadToEnd();
                        if (error.Trim().Length > 0)
                        {
                            Log.Warn().WriteLine("Error:\n{0}", error);
                        }
                    }
                    Log.Info().WriteLine("Finished : {0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
                    return(process.ExitCode);
                }
            }
            return(-1);
        }
        public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);

            // force password check to take place before the pages load
            if (!ConfluencePlugin.ConfluenceConnector.isLoggedIn)
            {
                return(exportInformation);
            }

            Page   selectedPage = page;
            bool   openPage     = (page == null) && config.OpenPageAfterUpload;
            string filename     = FilenameHelper.GetFilenameWithoutExtensionFromPattern(coreConfig.OutputFileFilenamePattern, captureDetails);

            if (selectedPage == null)
            {
                ConfluenceUpload confluenceUpload = new ConfluenceUpload(filename);
                Nullable <bool>  dialogResult     = confluenceUpload.ShowDialog();
                if (dialogResult.HasValue && dialogResult.Value)
                {
                    selectedPage = confluenceUpload.SelectedPage;
                    if (confluenceUpload.isOpenPageSelected)
                    {
                        openPage = false;
                    }
                    filename = confluenceUpload.Filename;
                }
            }
            string extension = "." + config.UploadFormat;

            if (!filename.ToLower().EndsWith(extension))
            {
                filename = filename + extension;
            }
            if (selectedPage != null)
            {
                string errorMessage;
                bool   uploaded = upload(surface, selectedPage, filename, out errorMessage);
                if (uploaded)
                {
                    if (openPage)
                    {
                        try {
                            Process.Start(selectedPage.Url);
                        } catch { }
                    }
                    exportInformation.ExportMade = true;
                    exportInformation.Uri        = selectedPage.Url;
                }
                else
                {
                    exportInformation.ErrorMessage = errorMessage;
                }
            }
            ProcessExport(exportInformation, surface);
            return(exportInformation);
        }
Ejemplo n.º 25
0
        public void SetIdWithSubfoldersTest()
        {
            var filenameHelper = new FilenameHelper();
            var filename       = "/Subfolder1/Subfolder2/My Markdown File.md";
            var id             = "2345";
            var result         = filenameHelper.SetId(filename, id);

            Assert.AreEqual("/Subfolder1/Subfolder2/My Markdown File[_2345].md", result);
        }
Ejemplo n.º 26
0
        public void ChangeIdTest()
        {
            var filenameHelper = new FilenameHelper();
            var filename       = "My Markdown File[_1234].md";
            var id             = "2345";
            var result         = filenameHelper.SetId(filename, id);

            Assert.AreEqual("My Markdown File[_2345].md", result);
        }
Ejemplo n.º 27
0
        public void WhenGuessedFilenameIsSetReturnTheGuessedFilename()
        {
            var filenameHelper = new FilenameHelper();

            filenameHelper.SetGuessedWordsFilename("SomeGuesssedFile.json");
            var filename = filenameHelper.GetGuessedWordsFilename();

            filename.Should().Be("SomeGuesssedFile.json");
        }
Ejemplo n.º 28
0
        public void WhenDictionaryFilenameIsSetReturnTheDictionaryFilename()
        {
            var filenameHelper = new FilenameHelper();

            filenameHelper.SetDictionaryFilename("SomeDictionaryFile.json");
            var filename = filenameHelper.GetDictionaryFilename();

            filename.Should().Be("SomeDictionaryFile.json");
        }
Ejemplo n.º 29
0
        public string BuildDeviceFilePath(DeviceType deviceType, string tag, string extension)
        {
            string filename = $"{deviceType.Code}_{tag}.{extension.Trim('.')}";

            string path = Path.Combine(RootPath, FilenameHelper.ReplaceInvalidFileNameChars(filename));

            _paths.Add(path);

            return(path);
        }
Ejemplo n.º 30
0
        public string BuildFilePath(string name, string format)
        {
            string filename = $"{name}.{format.Trim('.')}";

            string path = Path.Combine(RootPath, FilenameHelper.ReplaceInvalidFileNameChars(filename));

            _paths.Add(path);

            return(path);
        }