Пример #1
0
        void ProcessDesktopProfiles(object sender, EventArgs eventArgs)
        {
			NewProtectSimpleDialog psd = sender as NewProtectSimpleDialog;
			if (psd == null)
			{
                Logger.LogError("NewProtectSimpleDialog is null");
				return;
			}

			string profileLocation = psd.SelectedProfile;
            m_profileLocation = profileLocation;
			if (psd.ShowAdvancedOptions)
			{
				ResetPolicyCache();// Clear any previously selected profiles 
				AddProtectSimpleProfile(profileLocation);// Add selected profile, eg what the advanced protect dialog will show as triggered.

				// Proceed to show the protect standard (email security) dialog, and let things happen		
				ShowAdvancedOptions(sender);
				return;
			}

            // if large attachments are there, then we can just do Send Link on them
            if (!AllowActionForLargeAttachments(m_profileLocation) && eventArgs is DoWorkEventArgs)
            {
                ((DoWorkEventArgs)eventArgs).Cancel = true;
                return;
            }

            // copy over large attachments, if any
            CopyLargeAttachments();

            if (m_processResult == ProcessResult.EXCEPTION && eventArgs is DoWorkEventArgs)
			{
                ((DoWorkEventArgs)eventArgs).Cancel = true;
				return;
			}

            // Make sure that progress output is directed to the Protect Simple dialog, otherwise, if the advanced progress dialog
            // has been used, the user will see that pop up instead of showing progress within the Simple dialog itself.
            m_policyClientProgressDialog = psd;
			m_policyClientProgressDialog.SetDescription(Resources.INITIALISEPROTECTENGINE);
			m_policyClientProgressDialog.SetSubDescription("");

			// Ok the Policy Protect Process Dialog has a start and end method on it so lets dynamically get
			// it as we can't get a direct reference to it.
			MethodInfo startMethod = m_policyClientProgressDialog.GetType().GetMethod("Start");
			if (startMethod != null)
			{
				startMethod.Invoke(m_policyClientProgressDialog, null);
			}

			PrepareProtectSimpleResponse(profileLocation);

			MethodInfo stopMethod = m_policyClientProgressDialog.GetType().GetMethod("Stop");
			if (stopMethod != null)
			{
				stopMethod.Invoke(m_policyClientProgressDialog, null);
			}

			if (m_uiResponse.BlockingActions.Count > 0)
			{
				m_processResult = ClientManager.ProcessResult.BLOCKED_BY_POLICY;
				m_bUpdateProcessResult = false;
                return;
			}
			
            if (!(m_processResult == ProcessResult.NO_ACTIONS || m_processResult == ProcessResult.NO_VIOLATIONS || m_processResult == ClientManager.ProcessResult.ERRORS))
			{
				ProcessProtectSimpleResponse(m_policyClientProgressDialog);
                        
                UserEventAnalyser.SendEvent(UserEventAnalyser.EventName.SimpleSend, new Dictionary<string, object>()
                    {
                        {"Profile Type", m_uiResponse.Request.PolicyType},
                        {"Profile Name", psd.SelectedProfileName}
                    });

                return;
			}

			// We can't update processResult as there is no processing to be done after this.
			// We need to retain this processResult so that OutlookHookWorker doesn't try to play with attachments
			m_bUpdateProcessResult = false;
		}
Пример #2
0
		private DialogResult LoadStaticDiscoveryDialog(ref bool progressCreatedLocally, bool processAsync)
		{
			if (m_policyClientProgressDialog == null)
			{
				if (ShowProgress)
				{
					m_policyClientProgressDialog = m_uiManager.CreatePolicyClientProgressDialog();
					m_policyClientProgressDialog.SetDescription(Resources.PROGRESS_DESC_PROCESSING);
					progressCreatedLocally = true;
				}
			}

			// The progress dialog gets updated all over the place so rather than
			// trying to trap all of those events (and skip them if showprogress == false)
			// just set a local 'showprogress' within the dialog itself and let that code handle it.
			if (ShowProgress)
			{
				m_policyClientProgressDialog.ShouldShowProgress = ShowProgress;
				m_policyClientProgressDialog.SetSteps(6);
				UpdatePolicyClientProgress(Resources.PROGRESS_STATE_INITIALIZING);
			}

			StartScanningThread();
			// Stuff is happening here on the EngineWorker - thread
			while (!m_engineThread.Join(5))
			{
				// TODO: How long should we wait?  Maybe we need to have a timeout.
				Application.DoEvents();
			}

			if (m_processResult != ProcessResult.UNDEFINED)
			{
				if (ShowProgress)
				{
					m_policyClientProgressDialog.Complete();
					m_policyClientProgressDialog.Refresh();
					m_policyClientProgressDialog.Hide();
				}
				return DialogResult.None;
			}

            m_policyClientDialog = m_uiManager.CreatePolicyClientDialog2();

            if (!processAsync)// Async processing will be carried out in another thread, so don't give the dialog a callback
            {
                m_policyClientDialog.ProcessResponseActions += responseDialog_ProcessResponseActions;
            }
            m_policyClientDialog.PreviewResponseAction += policyClientDialog_PreviewResponseAction;

            m_policyClientDialog.SetResponse(m_uiResponse);
            if (ShowProgress)
            {
                m_policyClientProgressDialog.Complete();
                m_policyClientProgressDialog.Refresh();
            }

            if (m_policyClientProgressDialog != null && m_policyClientProgressDialog.Visible)
            {
                m_policyClientProgressDialog.Hide();
            }

            PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.SendToDialogShow, 0);

            m_isInitialised = true;// Engine thread has done its stuff, so no need for us to call it again later(when async processing)

		    m_policyClientDialog.HideWhenProcessingActions = false;

            IntPtr parentHwnd = m_uiManager.ParentHwnd;

            ResponseAnalyser.CollectAndStoreDefaultsEvents(m_response, ResponseAnalyser.EventType.Action);

            return m_policyClientDialog.ShowDialog(new ParentWindow(parentHwnd));		    
		}