/// <summary>
        /// Create a repository publish engine for the specified local repository to the remote server.
        /// </summary>
        /// <param name="productName">Required. The product to restrict sending to.</param>
        /// <param name="applicationName">Optional.  The application to restrict sending to.</param>
        /// <param name="directory">Optional.  The base directory of the repository, overriding the system default.</param>
        /// <param name="serverConfiguration">The server to publish to.</param>
        public RepositoryPublishEngine(string productName, string applicationName, string directory,
                                       ServerConfiguration serverConfiguration)
        {
            if (serverConfiguration == null)
            {
                throw new ArgumentNullException(nameof(serverConfiguration));
            }

            if (string.IsNullOrWhiteSpace(productName))
            {
                throw new ArgumentNullException(nameof(productName));
            }

            m_ProductName                = productName;
            m_ApplicationName            = applicationName;
            m_Configuration              = serverConfiguration;
            m_SessionPublishThreadFailed = true;  //otherwise we won't start it when we need to.

            //find the repository path we're using.  We use the same logic that the FileMessenger users.
            m_RepositoryFolder = LocalRepository.CalculateRepositoryPath(productName, directory);

            //create the correct lock name for our scope.
            m_MultiprocessLockName = BaseMultiprocessLockName + "~" + productName +
                                     (string.IsNullOrEmpty(applicationName) ? string.Empty : "~" + applicationName);

            //we have to make sure the multiprocess lock doesn't have any unsafe characters.
            m_MultiprocessLockName = FileSystemTools.SanitizeFileName(m_MultiprocessLockName);

            BackgroundStartupDelay = 0;
        }
Пример #2
0
        public void File_Spaces_Are_Not_Removed()
        {
            var originalValue = "THIS IS UPPER CASE";
            var testValue     = FileSystemTools.SanitizeFileName(originalValue, false, true);

            Assert.That(testValue.Contains(" "));
        }
Пример #3
0
        public void File_Is_Lower_Case()
        {
            var originalValue = "THIS IS UPPER CASE";
            var testValue     = FileSystemTools.SanitizeFileName(originalValue, false, true);

            Assert.That(originalValue.ToLowerInvariant(), Is.EqualTo(testValue));
        }
Пример #4
0
        private string MakeFileName()
        {
            string fileName = string.Format(CultureInfo.InvariantCulture, "{0} {1:yyyy-MM-dd-HH-mm-ss}-{2}.{3}", SessionFileNamePrefix(Publisher.SessionSummary.Product, Publisher.SessionSummary.Application),
                                            Publisher.SessionSummary.StartDateTime.UtcDateTime, m_CurrentSessionFile, LogExtension);

            return(FileSystemTools.SanitizeFileName(fileName));
        }
Пример #5
0
 public void File_Tabs_Are_Removed()
 {
     {
         var originalValue = "THIS\tIS\tUPPER\tCASE";
         var testValue     = FileSystemTools.SanitizeFileName(originalValue, false, true);
         Assert.That(testValue.Contains("\t") == false);
     }
 }
            public void AcceptsNull()
            {
                // ReSharper disable StringLiteralTypo
                var result   = FileSystemTools.SanitizeFileName(null);
                var expected = string.Empty;

                // ReSharper restore StringLiteralTypo
                Assert.AreEqual(expected, result);
            }
        private int m_FailedAttempts;                                 //PROTECTED BY THREADLOCK

        internal RepositoryPublishEngine(Publisher publisher, AgentConfiguration configuration)
        {
            m_ProductName                = publisher.SessionSummary.Product;
            m_ApplicationName            = publisher.SessionSummary.Application;
            m_Configuration              = configuration.Server;
            m_SessionPublishThreadFailed = true;  //otherwise we won't start it when we need to.

            //find the repository path we're using.  We use the same logic that the FileMessenger users.
            m_RepositoryFolder = LocalRepository.CalculateRepositoryPath(m_ProductName, configuration.SessionFile.Folder);

            //create the correct lock name for our scope.
            m_MultiprocessLockName = BaseMultiprocessLockName + "~" + m_ProductName +
                                     (m_Configuration.SendAllApplications ? string.Empty : "~" + m_ApplicationName);

            //we have to make sure the multiprocess lock doesn't have any unsafe characters.
            m_MultiprocessLockName = FileSystemTools.SanitizeFileName(m_MultiprocessLockName);
        }
Пример #8
0
 /// <summary>
 /// Creates the appropriate start of a session file name for a product/application
 /// </summary>
 /// <param name="productName"></param>
 /// <param name="applicationName"></param>
 /// <returns></returns>
 public static string SessionFileNamePrefix(string productName, string applicationName)
 {
     return(FileSystemTools.SanitizeFileName(string.Format(CultureInfo.InvariantCulture, "{0} {1}", productName, applicationName)));
 }