Beispiel #1
0
 public void MoveFolder(StoreId parentFolderId, StoreId destinationFolderId, StoreId sourceFolderId, string newFolderName)
 {
     using (PublicFolderConnectionLimitsTracker.Instance.GetToken(this.PrimaryHierarchyMailboxPrincipal.MailboxInfo.Location.ServerFqdn))
     {
         StoreSession storeSession = null;
         object       thisObject   = null;
         bool         flag         = false;
         try
         {
             if (storeSession != null)
             {
                 storeSession.BeginMapiCall();
                 storeSession.BeginServerHealthCall();
                 flag = true;
             }
             if (StorageGlobals.MapiTestHookBeforeCall != null)
             {
                 StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
             }
             using (MapiStore hierarchyStore = this.GetHierarchyStore())
             {
                 using (MapiFolder mapiFolder = (MapiFolder)hierarchyStore.OpenEntry(this.GetDestinationSpecificEntryId(hierarchyStore, parentFolderId)))
                 {
                     using (MapiFolder mapiFolder2 = (MapiFolder)hierarchyStore.OpenEntry(this.GetDestinationSpecificEntryId(hierarchyStore, destinationFolderId)))
                     {
                         mapiFolder.CopyFolder(CopyFolderFlags.FolderMove, mapiFolder2, this.GetDestinationSpecificEntryId(hierarchyStore, sourceFolderId), newFolderName);
                     }
                 }
             }
         }
         catch (MapiPermanentException ex)
         {
             throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCopyMessagesFailed, ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
             {
                 string.Format("RPCPrimaryHierarchyProvider.MoveFolder : folderId = {0}, ParentId = {1}, DestinationId = {2}", sourceFolderId, parentFolderId, destinationFolderId),
                 ex
             });
         }
         catch (MapiRetryableException ex2)
         {
             throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCopyMessagesFailed, ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
             {
                 string.Format("RPCPrimaryHierarchyProvider.MoveFolder : folderId = {0}, ParentId = {1}, DestinationId = {2}", sourceFolderId, parentFolderId, destinationFolderId),
                 ex2
             });
         }
         finally
         {
             try
             {
                 if (storeSession != null)
                 {
                     storeSession.EndMapiCall();
                     if (flag)
                     {
                         storeSession.EndServerHealthCall();
                     }
                 }
             }
             finally
             {
                 if (StorageGlobals.MapiTestHookAfterCall != null)
                 {
                     StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                 }
             }
         }
     }
 }