public async Task SendUsageStatistics_JobUsageStatsMetricHoldsProperValues()
        {
            var job      = BuildJob();
            var duration = TimeSpan.MaxValue;
            var status   = "test status";
            var product  = _applicationNameProvider.ApplicationNameWithEdition.ToLower().Replace(" ", "_");

            JobUsageStatisticsMetric metric = new JobUsageStatisticsMetric();

            _usageStatisticsManager.EnableUsageStatistics = true;

            _usageStatisticsSender.When(sender => sender.SendAsync(Arg.Any <IUsageMetric>())).Do(info =>
            {
                metric = info.Arg <JobUsageStatisticsMetric>();
            });

            await _usageStatisticsManager.SendUsageStatistics(duration, job, status);

            Assert.AreEqual("JobMetric", metric.EventName);
            Assert.AreEqual(product, metric.Product);
            Assert.AreEqual(_machineIdGenerator.GetMachineId(), metric.MachineId);
            Assert.AreEqual(_versionHelper.ApplicationVersion, metric.Version);
            Assert.AreEqual(OutputFormat.Pdf.ToString(), metric.OutputFormat);
            Assert.AreEqual(status, metric.Status);
            Assert.AreEqual((long)duration.TotalMilliseconds, metric.Duration);
            Assert.AreEqual(job.JobInfo.TotalPages, metric.TotalPages);
            Assert.AreEqual(job.NumberOfCopies, metric.NumberOfCopies);

            Assert.AreEqual(job.Profile.DropboxSettings.Enabled, metric.Dropbox);
            Assert.AreEqual(job.Profile.Ftp.Enabled, metric.Ftp);
            Assert.AreEqual(job.Profile.EmailSmtpSettings.Enabled, metric.Smtp);
            Assert.AreEqual(job.Profile.HttpSettings.Enabled, metric.Http);
            Assert.AreEqual(job.Profile.Printing.Enabled, metric.Print);

            Assert.AreEqual(job.Profile.CoverPage.Enabled, metric.Cover);
            Assert.AreEqual(job.Profile.BackgroundPage.Enabled, metric.Background);
            Assert.AreEqual(job.Profile.AttachmentPage.Enabled, metric.Attachment);
            Assert.AreEqual(job.Profile.Stamping.Enabled, metric.Stamp);

            Assert.AreEqual(job.Profile.PdfSettings.Security.Enabled, metric.Encryption);
            Assert.AreEqual(job.Profile.PdfSettings.Signature.Enabled, metric.Signature);

            Assert.AreEqual(job.Profile.Scripting.Enabled, metric.Script);
            Assert.AreEqual(job.Profile.CustomScript.Enabled, metric.CustomScript);
            Assert.AreEqual(job.Profile.UserTokens.Enabled, metric.UserToken);
        }
        public void SendPdfCreatorStatistics_UsageStatsMetricHoldsProperValues()
        {
            var job      = BuildJob();
            var duration = TimeSpan.MaxValue;
            var status   = "test status";
            PdfCreatorUsageStatisticsMetric metric = new PdfCreatorUsageStatisticsMetric();

            _settingsProvider.Settings.ApplicationSettings.UsageStatistics.Enable = true;
            _gpoSettings.DisableUsageStatistics.Returns(false);

            _threadManager.When(x => x.StartSynchronizedThread(Arg.Any <ISynchronizedThread>()))
            .Do(info =>
            {
                var t = info.Arg <ISynchronizedThread>();
                t.Start();
                t.Join();
            });

            _usageStatisticsSender.When(sender => sender.Send(Arg.Any <IUsageMetric>())).Do(info =>
            {
                metric = info.Arg <PdfCreatorUsageStatisticsMetric>();
            });

            _pdfCreatorUsageStatisticsManager.SendUsageStatistics(duration, job, status);

            Assert.AreEqual(_machineIdGenerator.GetMachineId(), metric.MachineId);
            Assert.AreEqual(OutputFormat.Pdf.ToString(), metric.OutputFormat);
            Assert.AreEqual(Mode.AutoSave, metric.Mode);
            Assert.AreEqual(job.Profile.ShowQuickActions, metric.QuickActions);

            Assert.AreEqual(job.Profile.OpenViewer, metric.OpenViewer);
            Assert.AreEqual(job.Profile.OpenWithPdfArchitect, metric.OpenWithPdfArchitect);
            Assert.AreEqual(job.JobInfo.TotalPages, metric.TotalPages);
            Assert.AreEqual(job.NumberOfCopies, metric.NumberOfCopies);

            Assert.AreEqual(_versionHelper.ApplicationVersion.ToString(), metric.Version);
            Assert.AreEqual((long)duration.TotalMilliseconds, metric.Duration);

            Assert.AreEqual(job.Profile.DropboxSettings.Enabled, metric.Dropbox);
            Assert.AreEqual(job.Profile.Ftp.Enabled, metric.Ftp);
            Assert.AreEqual(job.Profile.EmailSmtpSettings.Enabled, metric.Smtp);
            Assert.AreEqual(job.Profile.EmailClientSettings.Enabled, metric.Mailclient);
            Assert.AreEqual(job.Profile.HttpSettings.Enabled, metric.Http);
            Assert.AreEqual(job.Profile.Printing.Enabled, metric.Print);

            Assert.AreEqual(job.Profile.CoverPage.Enabled, metric.Cover);
            Assert.AreEqual(job.Profile.BackgroundPage.Enabled, metric.Background);
            Assert.AreEqual(job.Profile.AttachmentPage.Enabled, metric.Attachment);
            Assert.AreEqual(job.Profile.Stamping.Enabled, metric.Stamp);

            Assert.AreEqual(job.Profile.PdfSettings.Security.Enabled, metric.Encryption);
            Assert.AreEqual(job.Profile.PdfSettings.Signature.Enabled, metric.Signature);
            Assert.AreEqual(job.Profile.Scripting.Enabled, metric.Script);
            Assert.AreEqual(job.Profile.CustomScript.Enabled, metric.CustomScript);
            Assert.AreEqual(job.Profile.UserTokens.Enabled, metric.UserToken);

            Assert.AreEqual(status, metric.Status);
        }
Пример #3
0
        private JobUsageStatisticsMetric CreateJobUsageStatisticsMetric(Job job, TimeSpan duration, string status)
        {
            var usageStatisticsMetric = new JobUsageStatisticsMetric
            {
                Product      = GetApplicationName(),
                MachineId    = _machineIdGenerator.GetMachineId(),
                OutputFormat = job.Profile.OutputFormat.ToString(),

                TotalPages     = job.JobInfo.TotalPages,
                NumberOfCopies = job.NumberOfCopies,

                Version  = _versionHelper?.ApplicationVersion?.ToString(),
                Duration = (long)duration.TotalMilliseconds,

                Dropbox = job.Profile.DropboxSettings.Enabled,
                Ftp     = job.Profile.Ftp.Enabled,
                Smtp    = job.Profile.EmailSmtpSettings.Enabled,
                Http    = job.Profile.HttpSettings.Enabled,
                Print   = job.Profile.Printing.Enabled,

                Cover      = job.Profile.CoverPage.Enabled,
                Background = job.Profile.BackgroundPage.Enabled,
                Attachment = job.Profile.AttachmentPage.Enabled,
                Stamp      = job.Profile.Stamping.Enabled,

                Encryption = job.Profile.PdfSettings.Security.Enabled,
                Signature  = job.Profile.PdfSettings.Signature.Enabled,
                DisplaySignatureInDocument = job.Profile.PdfSettings.Signature.Enabled &&
                                             job.Profile.PdfSettings.Signature.DisplaySignatureInDocument,
                Script       = job.Profile.Scripting.Enabled,
                CustomScript = job.Profile.CustomScript.Enabled,
                UserToken    = job.Profile.UserTokens.Enabled,

                Status = status
            };

            return(usageStatisticsMetric);
        }
        public void SetUp()
        {
            _osHelper      = Substitute.For <IOsHelper>();
            _versionHelper = Substitute.For <IVersionHelper>();
            _versionHelper.ApplicationVersion.Returns(info => new Version());
            _usageStatisticsSender = Substitute.For <IUsageStatisticsSender>();
            _machineIdGenerator    = Substitute.For <IMachineIdGenerator>();
            _machineIdGenerator.GetMachineId().Returns("testmachinid");
            _applicationNameProvider = new ApplicationNameProvider("testedition");
            _settings         = new PdfCreatorSettings();
            _settingsProvider = Substitute.For <ISettingsProvider>();
            _settingsProvider.Settings.Returns(_settings);
            _gpoSettings   = Substitute.For <IGpoSettings>();
            _threadManager = Substitute.For <IThreadManager>();

            _pdfCreatorUsageStatisticsManager = BuildPdfCreatorUsageStatisticsManager(_threadManager);
        }
Пример #5
0
        private PdfCreatorUsageStatisticsMetric CreateJobUsageStatisticsMetric(Job job, TimeSpan duration, string status)
        {
            var pdfCreatorUsageStatisticsMetric = new PdfCreatorUsageStatisticsMetric
            {
                Product         = GetApplicationName(),
                MachineId       = _machineIdGenerator.GetMachineId(),
                OperatingSystem = _osHelper.GetWindowsVersion(),
                OutputFormat    = job.Profile.OutputFormat.ToString(),
                Mode            = GetMode(job.Profile.AutoSave.Enabled),
                QuickActions    = job.Profile.ShowQuickActions,

                OpenViewer           = job.Profile.OpenViewer,
                OpenWithPdfArchitect = job.Profile.OpenWithPdfArchitect,
                TotalPages           = job.JobInfo.TotalPages,
                NumberOfCopies       = job.NumberOfCopies,

                Version  = _versionHelper?.ApplicationVersion?.ToString(),
                Duration = (long)duration.TotalMilliseconds,

                Dropbox    = job.Profile.DropboxSettings.Enabled,
                Ftp        = job.Profile.Ftp.Enabled,
                Smtp       = job.Profile.EmailSmtpSettings.Enabled,
                Mailclient = job.Profile.EmailClientSettings.Enabled,
                Http       = job.Profile.HttpSettings.Enabled,
                Print      = job.Profile.Printing.Enabled,

                Cover      = job.Profile.CoverPage.Enabled,
                Background = job.Profile.BackgroundPage.Enabled,
                Attachment = job.Profile.AttachmentPage.Enabled,
                Stamp      = job.Profile.Stamping.Enabled,

                Encryption = job.Profile.PdfSettings.Security.Enabled,
                Signature  = job.Profile.PdfSettings.Signature.Enabled,
                DisplaySignatureInDocument = job.Profile.PdfSettings.Signature.Enabled &&
                                             job.Profile.PdfSettings.Signature.DisplaySignatureInDocument,

                Script       = job.Profile.Scripting.Enabled,
                CustomScript = job.Profile.CustomScript.Enabled,
                UserToken    = job.Profile.UserTokens.Enabled,
                IsShared     = job.Profile.Properties.IsShared,

                DisableApplicationSettings = _gpoSettings.DisableApplicationSettings,
                DisableDebugTab            = _gpoSettings.DisableDebugTab,
                DisablePrinterTab          = _gpoSettings.DisablePrinterTab,
                DisableProfileManagement   = _gpoSettings.DisableProfileManagement,
                DisableTitleTab            = _gpoSettings.DisableTitleTab,
                DisableAccountsTab         = _gpoSettings.DisableAccountsTab,
                DisableRssFeed             = _gpoSettings.DisableRssFeed,
                DisableTips              = _gpoSettings.DisableTips,
                HideLicenseTab           = _gpoSettings.HideLicenseTab,
                HidePdfArchitectInfo     = _gpoSettings.HidePdfArchitectInfo,
                GpoLanguage              = _gpoSettings.Language ?? "",
                GpoUpdateInterval        = _gpoSettings.UpdateInterval ?? "",
                LoadSharedAppSettings    = _gpoSettings.LoadSharedAppSettings,
                LoadSharedProfiles       = _gpoSettings.LoadSharedProfiles,
                AllowUserDefinedProfiles = _gpoSettings.AllowUserDefinedProfiles,

                Status = status
            };

            return(pdfCreatorUsageStatisticsMetric);
        }