Пример #1
0
		public ProcessResult ProcessRequest(IPolicyClientProgressDialog progress, bool showProgress, bool enableDynamicDiscovery)
		{
			Logger.LogDebug("Workshare.Policy.ClientManager.RequestManager.ProcessRequest()");

			if (m_request == null)
			{
				m_processResult = ProcessResult.NO_VIOLATIONS;
				return m_processResult;
			}

            if (!AllowActionForLargeAttachments(m_profileLocation))
            {
                return m_processResult;
            }

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

			bool progressCreatedLocally = false;
		    try
			{
				bool hasAttachments = HasSignificantAttachments();
				if (enableDynamicDiscovery && !hasAttachments)
				{
					showProgress = false;
				}

				ShowProgress = showProgress;
				m_encryptionUi = m_uiManager.CreateContentEncryptionUi();
				m_enableDynamicDiscovery = enableDynamicDiscovery;
				m_skipDiscovery = false;

                DialogResult dialogResult;
			    if (m_enableDynamicDiscovery && !this.SendAndProtect && hasAttachments)
				{
					dialogResult = LoadDynamicDiscoveryDialog(false);
				}
				else
				{
					m_policyClientProgressDialog = progress;
					dialogResult = LoadStaticDiscoveryDialog(ref progressCreatedLocally, false);
				}

                if (dialogResult == DialogResult.None && m_processResult != ProcessResult.UNDEFINED)
                {
                    return m_processResult;
                }

                while (m_policyClientDialog.AbortActions)
                {
                    m_policyClientDialog.AbortActions = false;
                    m_policyClientDialog.ContentPanelStyle = ContentPanelStyleEnum.PolicySummary;
                    dialogResult = m_policyClientDialog.ShowDialog(new ParentWindow(m_uiManager.ParentHwnd));
                }

				m_processResult = ProcessRequestErrors(dialogResult);
			}
			catch (Exception ex)
			{
				Logger.LogError(ex);

				StringBuilder sb = new StringBuilder(Resources.CRITICAL_EXCEPTION);
				sb.Append(' ');
				sb.Append(Resources.CONTACT_SYSTEM_ADMIN);

				m_errors.Add(sb.ToString());
				m_exceptions.Add(ex);

				m_processResult = ProcessResult.EXCEPTION;
			}
			finally
			{
				m_engineThread = null;

				StartOfficeApplicationTimeout();

				if (m_policyClientDialog != null)
				{
					m_policyClientDialog.ProcessResponseActions -= responseDialog_ProcessResponseActions;
					m_policyClientDialog.PreviewResponseAction -= policyClientDialog_PreviewResponseAction;
				}

				// If we're creating this locally, we need to make sure Dispose is called on it
				// See comment at top for further information
				if (progressCreatedLocally)
				{
					m_policyClientProgressDialog.Refresh();
					m_policyClientProgressDialog.Close();
					IDisposable disp = m_policyClientProgressDialog;
					if (disp != null)
					{
						disp.Dispose();
					}
				}
			}

			if (m_uiManager != null)
			{
				m_processResult = m_uiManager.HandleInvalidProcessResult(m_processResult, Errors, Exceptions);
			}

			return m_processResult;
		}
Пример #2
0
		public ProcessResult ProcessRequestForProtectSimple(bool displayProgress, bool isCorporateAccount)
		{
			try
			{
				ShowProgress = displayProgress;
				m_bUpdateProcessResult = true;
				m_encryptionUi = m_uiManager.CreateContentEncryptionUi();

                m_bUseServerProfiles = isCorporateAccount && !OptionApi.GetBool("UseClientProfiles");

				var psd = new NewProtectSimpleDialog(m_bUseServerProfiles)
				{
				    MRUProfile = GetClientProfileMru(),
				    ShowInTaskbar = false
				};
			    m_policyClientProgressDialog = psd;
				m_policyClientProgressDialog.ShouldShowProgress = displayProgress;

				psd.ProtectSimpleProfiles = this.ProtectSimpleProfiles;

				if (psd.ShouldShowTheDialog)
				{
					psd.OnProcessProfile += OnProtectSimpleProcessProfile;

					if (IsSendForReview && IsLotusNotesMailClient)
					{
						Logger.LogInfo("Detected Lotus Notes - Showing window as Always on Top");
						psd.Topmost = true;
					}
					else
					{
						new System.Windows.Interop.WindowInteropHelper(psd).Owner = m_uiManager.ParentHwnd;
					}
		
					bool? dr = psd.ShowDialog();

					if (m_bUpdateProcessResult)
					{
						m_processResult = ProcessRequestErrors(dr, psd.DialogResultEx);
						if (m_processResult == ClientManager.ProcessResult.PROCESSED)
						{
							UpdateClientProfileMru(psd.MRUProfile);
						}
					}
				}
				else
				{
					m_processResult = ProcessResult.NO_ACTIONS;
				}
			}
			catch (Exception ex)
			{
				if (m_policyClientProgressDialog != null)
				{
					// m_policyClientProgressDialog in this case is pointing to Protect Simple Dialog, psd assigned above.
					// If an exception is thrown while the dialog is still on the screen, sometimes the dialog does not get
					// dismissed properly. Thats why we need to call close here.
					m_policyClientProgressDialog.Close();
				}

				Logger.LogError(ex);

				StringBuilder sb = new StringBuilder(Resources.CRITICAL_EXCEPTION);
				sb.Append(' ');
				sb.Append(Resources.CONTACT_SYSTEM_ADMIN);

				m_errors.Add(sb.ToString());
				m_exceptions.Add(ex);

				m_processResult = ProcessResult.EXCEPTION;
			}
			finally
			{
				StartOfficeApplicationTimeout();

				if (m_uiManager != null)
				{
					m_processResult = m_uiManager.HandleInvalidProcessResult(m_processResult, Errors, Exceptions);
				}

				ResetPolicyCache();

				if (m_encryptionUi != null)
				{
					m_encryptionUi.OnShowDialog -= new ShowDialogEvent(m_encryptionUi_OnShowDialog);
				}
			}

			return m_processResult;
		}
Пример #3
0
		private void ShowAdvancedOptions(object protectSimpleDlg)
		{
			NewProtectSimpleDialog psd = protectSimpleDlg as NewProtectSimpleDialog;
			if (psd == null)
			{
				return;
			}

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

            IPolicyClientUIManager2 m_uiManager = (IPolicyClientUIManager2)UIManagerFactory.CreateInstance("Workshare.Policy.ClientManager.ProtectDialog.ProtectPolicyClientUIManager2, Workshare.Policy.ClientManager");
                        
            IPolicyClientProgressDialog DialogProgress = m_uiManager.CreatePolicyClientProgressDialog();
			IBlockOwner dBlockOwner = DialogProgress as IBlockOwner;

			if (null != dBlockOwner)
			{
				dBlockOwner.SetOwner = new System.Windows.Interop.WindowInteropHelper(psd).Owner;
				dBlockOwner.BlockOwner = true;
			}

			DialogProgress.Description = "Please wait...";
            DialogProgress.SubDescription = "Initializing";
            DialogProgress.SetSteps(7);
            m_policyClientProgressDialog.Complete();
            m_policyClientProgressDialog.Hide();

            ProcessRequest( DialogProgress, ShowProgress, false );

            DialogProgress.Complete();
            DialogProgress.Close();

            m_policyClientProgressDialog = psd;

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

			if (m_processResult == ProcessResult.CANCELLED)
			{
				psd.AllowedToGo = false;
				if (psd.Visibility != System.Windows.Visibility.Visible)
				{
					psd.ShowDialog();
				}
				psd.EnableControls();
			}
            else 
			{
				// So if PES dialog has been cancelled, we need to update ProcessResult based on ProtectSimple dialog's DialogResult, later on, see below
				// else if PES dialog has been "Sent", we need to remember the ProcessResult, and dont mess with it.
				m_bUpdateProcessResult = false;
                if (m_processResult == ClientManager.ProcessResult.PROCESSED)
                {
                    psd.UpdateMru();
                    UpdateClientProfileMru(psd.MRUProfile);
                }
			}			
		}
Пример #4
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;
		}
Пример #5
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));		    
		}
		public TransparentActionProgressCallback(IPolicyClientProgressDialog progressDialog, int steps)
		{
			PolicyActionProgressDialog = progressDialog;
			PolicyActionProgressDialog.SetSteps(steps);
		}