Imports System Imports System.ComponentModel Imports System.Collections.Generic Imports System.Diagnostics Imports System.Text Imports DevExpress.ExpressApp Imports DevExpress.ExpressApp.Actions Imports DevExpress.Persistent.Base Imports DevExpress.XtraGrid.Views.Grid Imports DevExpress.XtraGrid.Views.Grid.ViewInfo Imports Microsoft.VisualBasic Imports System.Drawing Imports System.Collections Imports System.Windows.Forms Imports System.Data Imports DevExpress.ExpressApp.Win.Editors Imports DevExpress.Persistent.BaseImpl Imports DevExpress.ExpressApp.Win Imports Microsoft.Office Imports System.Runtime.InteropServices Imports DevExpress.ExpressApp.Utils Public Class DragAndDropCRMOutlookCustomers_VC Inherits DevExpress.ExpressApp.ViewController Private _CanEmailDrop As Boolean = True Private _Selection As New ArrayList Dim _ActSelection As Object Private _DoDragGridControl As DevExpress.XtraGrid.GridControl Private _DoDragGridView As DevExpress.XtraGrid.Views.Grid.GridView Private _DoDragGridControlOutlookEMailAttachments As DevExpress.XtraGrid.GridControl Private _DoDragGridViewOutlookEMailAttachments As DevExpress.XtraGrid.Views.Grid.GridView Private _ToDragGridControl As DevExpress.XtraGrid.GridControl Private _ToDragGridView As DevExpress.XtraGrid.Views.Grid.GridView Private _ToDragGridControlCustomers As DevExpress.XtraGrid.GridControl Private _ToDragGridViewCustomers As DevExpress.XtraGrid.Views.Grid.GridView Private _ToDragGridViewCustomersFileAttachment As DevExpress.XtraGrid.Views.Grid.GridView Private _ToDragGridControlCustomersFileAttachment As DevExpress.XtraGrid.GridControl Private downHitInfo As GridHitInfo = Nothing Dim _WaitFormClass As New WaitFormClass Public Sub New() MyBase.New() InitializeComponent() RegisterActions(components) End Sub Protected Overrides Sub OnViewControlsCreated() MyBase.OnViewControlsCreated() If View.Id = "OutlookEMailIn_OutlookEMailAttachments_ListView" Then Frame.GetController(Of DevExpress.ExpressApp.FileAttachments.Win.FileAttachmentListViewController)?.Active.SetItemValue("", False) Frame.GetController(Of Nuvolar.Module.Win.OutlookEmailVC).aAttachFile.Active.SetItemValue("", False) Dim _View As DevExpress.ExpressApp.ListView = TryCast(View, DevExpress.ExpressApp.ListView) _DoDragGridViewOutlookEMailAttachments = TryCast(_View.Editor, DevExpress.ExpressApp.Win.Editors.GridListEditor).GridView _DoDragGridViewOutlookEMailAttachments.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseUp _DoDragGridControlOutlookEMailAttachments = _DoDragGridViewOutlookEMailAttachments.GridControl AddHandler _DoDragGridViewOutlookEMailAttachments.MouseDown, AddressOf DoDragGridViewOutlookEMailAttachments_MouseDown_MouseDown AddHandler _DoDragGridViewOutlookEMailAttachments.MouseMove, AddressOf DoDragGridViewOutlookEMailAttachments_MouseDown_MouseMove AddHandler View.SelectionChanged, AddressOf OutlookEMailIn_OutlookEMailAttachments_ListView_SelectionChanged End If If View.Id = "Customers_ListView_CRM_Outlook" Then Dim _View As DevExpress.ExpressApp.ListView = TryCast(View, DevExpress.ExpressApp.ListView) _ToDragGridViewCustomers = TryCast(_View.Editor, DevExpress.ExpressApp.Win.Editors.GridListEditor).GridView _ToDragGridControlCustomers = _ToDragGridViewCustomers.GridControl AddHandler _ToDragGridControlCustomers.DragOver, AddressOf ToDragGridControlCustomers_DragOver AddHandler _ToDragGridControlCustomers.DragDrop, AddressOf ToDragGridControlCustomers_DragDrop End If If View.Id = "Customers_CustomersFileAttachment_ListView" Then Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)?.Active.SetItemValue("", False) Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)?.Active.SetItemValue("", False) Frame.GetController(Of DevExpress.ExpressApp.FileAttachments.Win.FileAttachmentListViewController)?.Active.SetItemValue("", False) Frame.GetController(Of DevExpress.ExpressApp.SystemModule.LinkUnlinkController)?.Active.SetItemValue("", False) Dim _View As DevExpress.ExpressApp.ListView = TryCast(View, DevExpress.ExpressApp.ListView) _ToDragGridViewCustomersFileAttachment = TryCast(_View.Editor, DevExpress.ExpressApp.Win.Editors.GridListEditor).GridView _ToDragGridControlCustomersFileAttachment = _ToDragGridViewCustomersFileAttachment.GridControl AddHandler _ToDragGridControlCustomersFileAttachment.DragOver, AddressOf ToDragGridControlCustomersFileAttachment_DragOver AddHandler _ToDragGridControlCustomersFileAttachment.DragDrop, AddressOf ToDragGridControlCustomersFileAttachment_DragDrop End If End Sub 'Protected Overrides Sub OnDeactivated() ' MyBase.OnDeactivated() ' 'If View.Id = "Customers_CustomersFileAttachment_ListView" Then ' ' Dim _View As DevExpress.ExpressApp.ListView = TryCast(View, DevExpress.ExpressApp.ListView) ' ' _ToDragGridViewCustomersFileAttachment = TryCast(_View.Editor, DevExpress.ExpressApp.Win.Editors.GridListEditor).GridView ' ' _ToDragGridControlCustomersFileAttachment = _ToDragGridViewCustomersFileAttachment.GridControl ' ' RemoveHandler _ToDragGridControlCustomersFileAttachment.DragOver, AddressOf ToDragGridControlCustomersFileAttachment_DragOver ' ' RemoveHandler _ToDragGridControlCustomersFileAttachment.DragDrop, AddressOf ToDragGridControlCustomersFileAttachment_DragDrop ' 'End If 'End Sub '------Subs as Functions------------- Private Function LoadOtherFile(ByVal _ActFile As String, _FileData As FileData) As FileData Dim _StreamFile = New System.IO.FileStream(_ActFile, System.IO.FileMode.Open, System.IO.FileAccess.Read) Dim _StreamReader As New System.IO.StreamReader(_StreamFile) _StreamFile.Seek(0, System.IO.SeekOrigin.Begin) _FileData.LoadFromStream(_ActFile, _StreamFile) _FileData.FileName = System.IO.Path.GetFileName(_ActFile) _StreamReader.Close() _StreamFile.Close() Return _FileData End Function Private Sub DoDragGridViewOutlookEMailAttachments_MouseDown_MouseDown(sender As Object, e As MouseEventArgs) Dim view As GridView = TryCast(sender, GridView) downHitInfo = Nothing Dim hitInfo As GridHitInfo = view.CalcHitInfo(New Point(e.X, e.Y)) If Control.ModifierKeys <> Keys.None Then Return End If If e.Button = MouseButtons.Left AndAlso hitInfo.InRow AndAlso hitInfo.HitTest <> GridHitTest.RowIndicator Then downHitInfo = hitInfo End If End Sub Private Sub DoDragGridViewOutlookEMailAttachments_MouseDown_MouseMove(sender As Object, e As MouseEventArgs) Dim view As GridView = TryCast(sender, GridView) If e.Button = MouseButtons.Left AndAlso downHitInfo IsNot Nothing Then Dim dragSize As Size = SystemInformation.DragSize Dim dragRect As New Rectangle(New Point(downHitInfo.HitPoint.X - dragSize.Width / 2, downHitInfo.HitPoint.Y - dragSize.Height / 2), dragSize) If (Not dragRect.Contains(New Point(e.X, e.Y))) Then view.GridControl.DoDragDrop(_Selection, DragDropEffects.All) downHitInfo = Nothing End If End If End Sub Private Sub OutlookEMailIn_OutlookEMailAttachments_ListView_SelectionChanged(sender As Object, e As EventArgs) _Selection.Clear() _Selection.AddRange(View.SelectedObjects) End Sub Private Sub ToDragGridControlCustomers_DragOver(sender As Object, e As DragEventArgs) e.Effect = DragDropEffects.Copy Dim _ListView As DevExpress.ExpressApp.ListView = TryCast(View, DevExpress.ExpressApp.ListView) If _ListView Is Nothing Then Return Dim _Grid As DevExpress.XtraGrid.GridControl = TryCast(sender, DevExpress.XtraGrid.GridControl) Dim _GridHitInfo As GridHitInfo = _Grid.MainView.CalcHitInfo(_Grid.PointToClient(New Point(e.X, e.Y))) ' If Not _ToDragGridViewCustomers.IsDataRow(_GridHitInfo.RowHandle) Then _ToDragGridViewCustomers.CollapseAllGroups() If _ToDragGridViewCustomers.IsGroupRow(_GridHitInfo.RowHandle) Then _ToDragGridViewCustomers.ExpandGroupRow(_GridHitInfo.RowHandle) If _ToDragGridViewCustomers.IsDataRow(_GridHitInfo.RowHandle) Then _ToDragGridViewCustomers.ClearSelection() _ToDragGridViewCustomers.SelectRow(_GridHitInfo.RowHandle) End If End Sub Private Sub ToDragGridControlCustomers_DragDrop(sender As Object, e As DragEventArgs) Try Dim _ListView As DevExpress.ExpressApp.ListView = TryCast(View, DevExpress.ExpressApp.ListView) If _ListView Is Nothing Then Return Dim _Grid As DevExpress.XtraGrid.GridControl = TryCast(sender, DevExpress.XtraGrid.GridControl) Dim _GridHitInfo As GridHitInfo = _Grid.MainView.CalcHitInfo(_Grid.PointToClient(New Point(e.X, e.Y))) If Not _GridHitInfo.InRow OrElse Not _GridHitInfo.InRowCell Then Return If Not DirectCast(_Grid.MainView, GridView).IsDataRow(_GridHitInfo.RowHandle) Then Return Dim _Customers As Customers = TryCast(_Grid.MainView.GetRow(_GridHitInfo.RowHandle), Customers) If _Customers Is Nothing Then Return Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _AttachmentSelection As ArrayList = e.Data.GetData(GetType(ArrayList)) If _AttachmentSelection IsNot Nothing Then If TryCast(_AttachmentSelection(0), OutlookEMailAttachments) Is Nothing Then Throw New InvalidCastException _WaitFormClass.InitWork(0, 1, _AttachmentSelection.Count) _Selection.Clear() For Each _OutlookEMailAttachments As OutlookEMailAttachments In _AttachmentSelection Dim _CustomersFileAttachment As New CustomersFileAttachment(_ocur.Session) With (_CustomersFileAttachment) .Customers = _ocur.GetObject(_Customers) .File = _ocur.GetObject(_OutlookEMailAttachments.DocumentFileData.File) .File.FileName = _OutlookEMailAttachments.DocumentFileData.File.FileName End With _OutlookEMailAttachments.OutlookEMailIn.IsReaded = True _OutlookEMailAttachments.OutlookEMailIn.Qualified = True _Selection.Add(_CustomersFileAttachment) _WaitFormClass.DoWork Next _ocur.CommitChanges() _Waitformclass.FinalWork CType(New PopupWindowShowActionHelper(Frame.GetController(Of DragAndDropCRMOutlookCustomers_VC).aDragDrop_CRM_Customer_Change), PopupWindowShowActionHelper).ShowPopupWindow() Else Dim _FileIn As Object = e.Data.GetData(DataFormats.FileDrop) If _FileIn IsNot Nothing Then _WaitFormClass.InitWork(0, 1, TryCast(_FileIn, String()).Length) _Selection.Clear() For Each _ActFile As String In _FileIn If System.IO.File.Exists(_ActFile) Then Dim _CustomersFileAttachmentNew As New CustomersFileAttachment(_ocur.Session) With (_CustomersFileAttachmentNew) .Customers = _ocur.GetObject(_Customers) .Status = eProductsDocumentationStatus.ePublic .File = LoadOtherFile(_ActFile, New FileData(_ocur.Session)) .ShortName = .File.FileName .FileCreated = GetFileCreatedDate(_ActFile) .FileModified = GetFileModifiedDate(_ActFile) End With _Selection.Add(_CustomersFileAttachmentNew) End If _WaitFormClass.DoWork Next _ocur.CommitChanges() _Waitformclass.FinalWork CType(New PopupWindowShowActionHelper(Frame.GetController(Of DragAndDropCRMOutlookCustomers_VC).aDragDrop_CRM_Customer_Change), PopupWindowShowActionHelper).ShowPopupWindow() Else If _CanEmailDrop Then _CanEmailDrop = False Dim _OL As Microsoft.Office.Interop.Outlook.Application = New Microsoft.Office.Interop.Outlook.Application _WaitFormClass.InitWork(0, 1, _OL.ActiveExplorer.Selection.Count) If _OL.ActiveExplorer.Selection.Count > 0 Then For ik As Long = 1 To _OL.ActiveExplorer.Selection.Count _FileIn = _OL.ActiveExplorer.Selection(ik) Dim _MailItem As Microsoft.Office.Interop.Outlook.MailItem = TryCast(_FileIn, Microsoft.Office.Interop.Outlook.MailItem) If _MailItem IsNot Nothing Then Dim _FileName As String = "" Dim _Subject As String = _MailItem.Subject.Replace(":", "") _Subject = _Subject.Replace("/", "-") _FileName = System.IO.Path.GetTempPath + _Subject + ".msg" _FileName = _FileName.Replace("\\", "\") _MailItem.SaveAs(_FileName, Microsoft.Office.Interop.Outlook.OlSaveAsType.olMSG) If System.IO.File.Exists(_FileName) Then Dim _CustomersFileAttachmentNew As New CustomersFileAttachment(_ocur.Session) With (_CustomersFileAttachmentNew) .Customers = _ocur.GetObject(_Customers) .Status = eProductsDocumentationStatus.ePublic .File = LoadOtherFile(_FileName, New FileData(_ocur.Session)) .ShortName = _MailItem.Sender.Name .FileCreated = _MailItem.CreationTime .FileModified = GetFileModifiedDate(_FileName) .Description = _MailItem.Subject End With _Selection.Add(_CustomersFileAttachmentNew) System.IO.File.Delete(_FileName) End If End If _WaitFormClass.DoWork Next _ocur.CommitChanges() _Waitformclass.FinalWork SwitchOutlookPanes(_OL) CType(New PopupWindowShowActionHelper(Frame.GetController(Of DragAndDropCRMOutlookCustomers_VC).aDragDrop_CRM_Customer_Change), PopupWindowShowActionHelper).ShowPopupWindow() End If End If _CanEmailDrop = True End If End If Catch ex As InvalidCastException MsgBox("Ügyfélhez nem lehet e-mailt rendeleni!", MsgBoxStyle.OkOnly, "Hiba!") Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub ToDragGridControlCustomersFileAttachment_DragOver(sender As Object, e As DragEventArgs) 'e.Effect = DragDropEffects.Copy Dim _ListView As DevExpress.ExpressApp.ListView = TryCast(View, DevExpress.ExpressApp.ListView) If _ListView Is Nothing Then Return Dim _Grid As DevExpress.XtraGrid.GridControl = TryCast(sender, DevExpress.XtraGrid.GridControl) Dim _GridHitInfo As GridHitInfo = _Grid.MainView.CalcHitInfo(_Grid.PointToClient(New Point(e.X, e.Y))) ' If Not _ToDragGridViewCustomersFileAttachment.IsDataRow(_GridHitInfo.RowHandle) Then _ToDragGridViewCustomersFileAttachment.CollapseAllGroups() If _ToDragGridViewCustomersFileAttachment.IsGroupRow(_GridHitInfo.RowHandle) Then _ToDragGridViewCustomersFileAttachment.ExpandGroupRow(_GridHitInfo.RowHandle) _ActSelection = Nothing If Not _ToDragGridViewCustomersFileAttachment.IsDataRow(_GridHitInfo.RowHandle) Then e.Effect = DragDropEffects.None _ToDragGridViewCustomersFileAttachment.Tag = "NODROP" ElseIf _ToDragGridViewCustomersFileAttachment.IsDataRow(_GridHitInfo.RowHandle) Then e.Effect = DragDropEffects.Copy _ToDragGridViewCustomersFileAttachment.ClearSelection() _ToDragGridViewCustomersFileAttachment.SelectRow(_GridHitInfo.RowHandle) _ActSelection = _ToDragGridViewCustomersFileAttachment.GetRow(_ToDragGridViewCustomersFileAttachment.GetSelectedRows(0)) _ToDragGridViewCustomersFileAttachment.Tag = "" End If End Sub Private Sub ToDragGridControlCustomersFileAttachment_DragDrop(sender As Object, e As DragEventArgs) 'Try If _ToDragGridViewCustomersFileAttachment.Tag = "NODROP" Then _ToDragGridViewCustomersFileAttachment.Tag = "" Return End If Dim _ListView As DevExpress.ExpressApp.ListView = TryCast(View, DevExpress.ExpressApp.ListView) If _ListView Is Nothing Then Return Dim _Grid As DevExpress.XtraGrid.GridControl = TryCast(sender, DevExpress.XtraGrid.GridControl) Dim _GridHitInfo As GridHitInfo = _Grid.MainView.CalcHitInfo(_Grid.PointToClient(New Point(e.X, e.Y))) Dim _Customer_CustomersFileAttachment As CustomersFileAttachment = Nothing If _ActSelection IsNot Nothing Then _Customer_CustomersFileAttachment = TryCast(_ActSelection, CustomersFileAttachment) Else If Not _GridHitInfo.InRow OrElse Not _GridHitInfo.InRowCell Then Return If Not DirectCast(_Grid.MainView, GridView).IsDataRow(_GridHitInfo.RowHandle) Then Return _Customer_CustomersFileAttachment = TryCast(_Grid.MainView.GetRow(_GridHitInfo.RowHandle), CustomersFileAttachment) End If If _Customer_CustomersFileAttachment Is Nothing Then Return Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _AttachmentSelection As ArrayList = e.Data.GetData(GetType(ArrayList)) If _AttachmentSelection IsNot Nothing Then _WaitFormClass.InitWork(0, 1, _AttachmentSelection.Count) For Each _OutlookEMailAttachments As OutlookEMailAttachments In _AttachmentSelection Dim _CustomersFileAttachment As New CustomersFileAttachment(_ocur.Session) With (_CustomersFileAttachment) .RowGroup1 = _Customer_CustomersFileAttachment.RowGroup1 .RowGroup2 = _Customer_CustomersFileAttachment.RowGroup2 .Status = eProductsDocumentationStatus.ePublic .Customers = _ocur.GetObject(_Customer_CustomersFileAttachment.Customers) .File = _ocur.GetObject(_OutlookEMailAttachments.DocumentFileData.File) .File.FileName = _OutlookEMailAttachments.DocumentFileData.File.FileName End With _OutlookEMailAttachments.OutlookEMailIn.IsReaded = True _OutlookEMailAttachments.OutlookEMailIn.Qualified = True _WaitFormClass.DoWork Next _ocur.CommitChanges() _Waitformclass.FinalWork Else Dim _FileIn As Object = e.Data.GetData(DataFormats.FileDrop) If _FileIn IsNot Nothing Then _WaitFormClass.InitWork(0, 1, TryCast(_FileIn, String()).Length) For Each _ActFile As String In _FileIn If System.IO.File.Exists(_ActFile) Then Dim _CustomersFileAttachmentNew As New CustomersFileAttachment(_ocur.Session) With (_CustomersFileAttachmentNew) .RowGroup1 = _Customer_CustomersFileAttachment.RowGroup1 .RowGroup2 = _Customer_CustomersFileAttachment.RowGroup2 .Status = eProductsDocumentationStatus.ePublic .Customers = _ocur.GetObject(_Customer_CustomersFileAttachment.Customers) .File = LoadOtherFile(_ActFile, New FileData(_ocur.Session)) .ShortName = .File.FileName .FileCreated = GetFileCreatedDate(_ActFile) .FileModified = GetFileModifiedDate(_ActFile) End With End If _WaitFormClass.DoWork Next _ocur.CommitChanges() _Waitformclass.FinalWork Else If _CanEmailDrop Then _CanEmailDrop = False Dim _OL As Microsoft.Office.Interop.Outlook.Application = New Microsoft.Office.Interop.Outlook.Application If _OL.ActiveExplorer.Selection.Count > 0 Then _WaitFormClass.InitWork(0, 1, _OL.ActiveExplorer.Selection.Count) For ik = 1 To _OL.ActiveExplorer.Selection.Count _FileIn = _OL.ActiveExplorer.Selection(ik) Dim _MailItem As Microsoft.Office.Interop.Outlook.MailItem = TryCast(_FileIn, Microsoft.Office.Interop.Outlook.MailItem) If _MailItem IsNot Nothing Then Dim _FileName As String = "" Dim _Subject As String = "" If _MailItem.Subject IsNot Nothing Then _Subject = _MailItem.Subject.Replace(":", "") _Subject = _Subject.Replace("/", "-") Else _Subject = "Nincs tárgy" End If If _Subject.Length > 16 Then _FileName = System.IO.Path.GetTempPath + _Subject.Remove(16, _Subject.Length - 16) + ".msg" Else _FileName = System.IO.Path.GetTempPath + _Subject + ".msg" End If _MailItem.SaveAs(_FileName, Microsoft.Office.Interop.Outlook.OlSaveAsType.olMSG) If System.IO.File.Exists(_FileName) Then Dim _CustomersFileAttachmentNew As New CustomersFileAttachment(_ocur.Session) With (_CustomersFileAttachmentNew) .RowGroup1 = _Customer_CustomersFileAttachment.RowGroup1 .RowGroup2 = _Customer_CustomersFileAttachment.RowGroup2 .Customers = _ocur.GetObject(_Customer_CustomersFileAttachment.Customers) .Status = eProductsDocumentationStatus.ePublic .File = LoadOtherFile(_FileName, New FileData(_ocur.Session)) .ShortName = _MailItem.Sender.Name .FileCreated = _MailItem.ReceivedTime 'Küldés dátuma kell? .FileModified = GetFileModifiedDate(_FileName) .Description = _MailItem.Subject End With _Selection.Add(_CustomersFileAttachmentNew) System.IO.File.Delete(_FileName) End If End If _WaitFormClass.DoWork Next _ocur.CommitChanges() _Waitformclass.FinalWork SwitchOutlookPanes(_OL) End If End If _CanEmailDrop = True End If End If 'Catch ex As Exception 'MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) 'End Try End Sub Private Sub aDragDrop_CRM_Customer_Change_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aDragDrop_CRM_Customer_Change.CustomizePopupWindowParams Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _ChangeFileAttachment_PopUp As ChangeFileAttachment_PopUp = _onew.CreateObject(Of ChangeFileAttachment_PopUp)() e.View = Application.CreateDetailView(_onew, "ChangeFileAttachment_PopUp_DetailView", True, _ChangeFileAttachment_PopUp) e.View.Tag = "aCustomersFileAttachment_ChangeGroup" Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aDragDrop_CRM_Customer_Change_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aDragDrop_CRM_Customer_Change.Execute Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _ChangeFileAttachment_PopUp As ChangeFileAttachment_PopUp = TryCast(e.PopupWindow.View.SelectedObjects(0), ChangeFileAttachment_PopUp) Dim _Customers As Customers = _onew.GetObject(TryCast(View.SelectedObjects(0), Customers)) _WaitFormClass.InitWork(1, 1, _Selection.Count) For Each _CustomersFileAttachment_Select As CustomersFileAttachment In _Selection Dim _CustomersFileAttachment As CustomersFileAttachment = _onew.GetObject(_CustomersFileAttachment_Select) If _ChangeFileAttachment_PopUp.ChangeRowGroup1 Then _CustomersFileAttachment.RowGroup1 = _ChangeFileAttachment_PopUp.RowGroup1 End If If _ChangeFileAttachment_PopUp.ChangeRowGroup2 Then _CustomersFileAttachment.RowGroup2 = _ChangeFileAttachment_PopUp.RowGroup2 End If If _ChangeFileAttachment_PopUp.ChangeStatus Then _CustomersFileAttachment.Status = _ChangeFileAttachment_PopUp.Status End If _WaitFormClass.DoWork Next _onew.CommitChanges() View.Refresh() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Finally _Waitformclass.FinalWork _Selection.Clear() End Try End Sub Private Function GetFileCreatedDate(_ActFile As String) As Date Return System.IO.File.GetCreationTime(_ActFile) End Function Private Function GetFileModifiedDate(_ActFile As String) As Date Return System.IO.File.GetLastAccessTime(_ActFile) End Function Public Sub SwitchOutlookPanes(_OL As Microsoft.Office.Interop.Outlook.Application) Dim _Explorer As Microsoft.Office.Interop.Outlook.Explorer = _OL.ActiveExplorer Try If _OL IsNot Nothing And _Explorer IsNot Nothing Then Dim nMAPIFOlder As Interop.Outlook.MAPIFolder = _Explorer.CurrentFolder Dim _NameSpace As Microsoft.Office.Interop.Outlook.NameSpace = _OL.GetNamespace("MAPI") If _NameSpace.Folders(1) IsNot Nothing Then If _NameSpace.Folders(1).Folders.Count > 0 Then If _NameSpace.Folders(1).Folders(_NameSpace.Folders(1).Folders.Count) IsNot Nothing Then If _NameSpace.Folders(1).Folders(_NameSpace.Folders(1).Folders.Count).Name <> nMAPIFOlder.Name Then _Explorer.CurrentFolder = _NameSpace.Folders(1).Folders(_NameSpace.Folders(1).Folders.Count) Else _Explorer.CurrentFolder = _NameSpace.Folders(1).Folders(1) End If End If End If End If System.Threading.Thread.Sleep(1000) _Explorer.CurrentFolder = nMAPIFOlder System.Threading.Thread.Sleep(1000) End If Catch ex As System.Exception Finally Marshal.ReleaseComObject(_Explorer) Marshal.ReleaseComObject(_OL) End Try End Sub End Class