Esempio n. 1
0
 public void Initialize(PluginEnvironment environment)
 {
     _activityData = new EPrintActivityData();
     documentSelectionControl.Initialize();
     exchange_ServerComboBox.Initialize("Exchange");
     ePrint_ServerComboBox.Initialize("ePrint");
 }
 /// <summary>
 /// Creates log entries for each attachment on the email.
 /// </summary>
 /// <param name="attachments">The attachments</param>
 /// <param name="ePrintData">The ePrintActivityData</param>
 private void LogAttachments(List <UniqueFile> attachments, EPrintActivityData activityData)
 {
     // Log each attachment as it's own print job
     foreach (UniqueFile printJob in attachments)
     {
         LogPrintJobData(printJob, activityData);
     }
 }
        private void LogPrintJobData(UniqueFile printJob, EPrintActivityData activityData)
        {
            PrintJobClientLog printJobClientLog = new PrintJobClientLog(_executionData, printJob, activityData.PrinterEmail, "ePrint", printJob.Id);

            try
            {
                ExecutionServices.DataLogger.Submit(printJobClientLog);
            }
            catch (Exception ex)
            {
                ExecutionServices.SystemTrace.LogError("Failed to log PrintJobClientLog data.", ex);
            }
        }
Esempio n. 4
0
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            // Initialize the activity data by deserializing it from the configuration information.
            _configData    = configuration;
            _activityData  = configuration.GetMetadata <EPrintActivityData>();
            _selectedAsset = ConfigurationServices.AssetInventory.GetAsset(_configData.Assets.SelectedAssets.FirstOrDefault());

            // Order is deterministic based on the way it was saved - exchange server first, then ePrint server
            exchange_ServerComboBox.Initialize(_configData.Servers.SelectedServers.FirstOrDefault(), "Exchange");
            ePrint_ServerComboBox.Initialize(_configData.Servers.SelectedServers.Skip(1).FirstOrDefault(), "ePrint");
            ePrint_ServerComboBox_SelectionChanged(ePrint_ServerComboBox, EventArgs.Empty);
            documentSelectionControl.Initialize(configuration.Documents, GetDocumentFilter());

            // Brute force initialization
            email_ComboBox.SelectedIndex      = email_ComboBox.FindString(_activityData.PrinterEmail);
            attachAll_RadioButton.Checked     = (_activityData.NumberOfDocuments == _configData.Documents.SelectedDocuments.Count);
            documentCount_NumericUpDown.Value = _activityData.NumberOfDocuments;
        }
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            _executionData = executionData;
            EPrintActivityData activityData = _executionData.GetMetadata <EPrintActivityData>();

            IAssetInfo assetInfo = _executionData.Assets.GetRandom();

            if (_emailController == null)
            {
                ServerInfo exchangeServerInfo = _executionData.Servers.Where(s => s.HostName.Contains("EXCHANGE", StringComparison.InvariantCultureIgnoreCase)).First();
                ConfigureEmailController(exchangeServerInfo, executionData.Credential);
            }

            if (_emailSubject == null)
            {
                _emailSubject = "SessionId:" + _executionData.SessionId;
            }

            UpdateUI(activityData.PrinterEmail);
            LogUsageData(assetInfo, _executionData.Servers);

            //Prepare the email attachments
            List <UniqueFile> attachments = null;

            // Lock the document pool so that we don't get conflicts with other users.
            ExecutionServices.CriticalSection.Run(new LocalLockToken("LocalDocument", new TimeSpan(0, 5, 0), new TimeSpan(0, 5, 0)), () =>
            {
                attachments = PrepareDocuments(activityData.NumberOfDocuments);
            });

            //Send the email
            SendEmail(activityData.PrinterEmail, _emailSubject, "Auto-generated by STF", attachments.ConvertAll(x => x.FileInfo));
            LogAttachments(attachments, activityData);

            CleanupPrintJobs(attachments);

            // Check email responses from the ePrint server
            Task.Factory.StartNew(() => CheckForServerResponses());

            return(new PluginExecutionResult(PluginResult.Passed));
        }