コード例 #1
0
        private void SynchronizeGroupAsyncWorker(object arg)
        {
            Exception error     = null;
            bool      cancelled = false;
            string    groupName = null;
            object    userState = null;

            try
            {
                SyncGroupHelper sgh = (SyncGroupHelper)arg;
                groupName = sgh.Group;
                userState = sgh.UserState;
                cancelled = this.SynchronizeGroupCore(false, sgh);
            }
            catch (Exception exception2)
            {
                if (ExceptionUtility.IsHardException(exception2))
                {
                    throw;
                }
                if (exception2 is DownloadCancelledException)
                {
                    cancelled = true;
                }
                else
                {
                    error = exception2;
                }
            }
            finally
            {
                SynchronizeCompletedEventArgs args = new SynchronizeCompletedEventArgs(error, cancelled, userState, groupName);
                this.asyncOperation.Post(this.synchronizeCompleted, args);
            }
        }
コード例 #2
0
 public void Synchronize(string groupName)
 {
     if (groupName == null)
     {
         this.Synchronize();
     }
     else
     {
         bool flag;
         if (this._actDesc == null)
         {
             throw new InvalidOperationException(Resources.GetString("Ex_BindFirst"));
         }
         if (!this._cached)
         {
             throw new InvalidOperationException(Resources.GetString("Ex_SyncNullFirst"));
         }
         SyncGroupHelper sgh = this.AttachToGroup(groupName, null, out flag);
         if (!flag)
         {
             throw new InvalidOperationException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_SyncGroupOnce"), new object[] { groupName }));
         }
         this.SynchronizeGroupCore(true, sgh);
     }
 }
コード例 #3
0
 public void SynchronizeAsync(string groupName, object userState)
 {
     if (groupName == null)
     {
         this.SynchronizeAsync();
     }
     else
     {
         bool flag;
         if (this._actDesc == null)
         {
             throw new InvalidOperationException(Resources.GetString("Ex_BindFirst"));
         }
         if (!this._cached)
         {
             throw new InvalidOperationException(Resources.GetString("Ex_SyncNullFirst"));
         }
         SyncGroupHelper state = this.AttachToGroup(groupName, userState, out flag);
         if (!flag)
         {
             throw new InvalidOperationException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_SyncGroupOnce"), new object[] { groupName }));
         }
         ThreadPool.QueueUserWorkItem(this.synchronizeGroupWorker, state);
     }
 }
コード例 #4
0
 public void Synchronize(string groupName)
 {
     if (groupName == null)
     {
         this.Synchronize();
     }
     else
     {
         if (this._actDesc == null)
         {
             throw new InvalidOperationException(Resources.GetString("Ex_BindFirst"));
         }
         if (!this._cached)
         {
             throw new InvalidOperationException(Resources.GetString("Ex_SyncNullFirst"));
         }
         bool            created;
         SyncGroupHelper group = this.AttachToGroup(groupName, (object)null, out created);
         if (created)
         {
             this.SynchronizeGroupCore(true, group);
         }
         else
         {
             throw new InvalidOperationException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_SyncGroupOnce"), new object[1]
             {
                 (object)groupName
             }));
         }
     }
 }
コード例 #5
0
 public void SynchronizeAsync(string groupName, object userState)
 {
     if (groupName == null)
     {
         this.SynchronizeAsync();
     }
     else
     {
         if (this._actDesc == null)
         {
             throw new InvalidOperationException(Resources.GetString("Ex_BindFirst"));
         }
         if (!this._cached)
         {
             throw new InvalidOperationException(Resources.GetString("Ex_SyncNullFirst"));
         }
         bool            created;
         SyncGroupHelper group = this.AttachToGroup(groupName, userState, out created);
         if (created)
         {
             ThreadPool.QueueUserWorkItem(this.synchronizeGroupWorker, (object)group);
         }
         else
         {
             throw new InvalidOperationException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_SyncGroupOnce"), new object[1]
             {
                 (object)groupName
             }));
         }
     }
 }
コード例 #6
0
        private void DetachFromGroup(SyncGroupHelper sgh)
        {
            string group = sgh.Group;

            lock (this._syncGroupMap.SyncRoot)
                this._syncGroupMap.Remove((object)group);
            sgh.SetComplete();
        }
コード例 #7
0
        private bool SynchronizeGroupCore(bool blocking, SyncGroupHelper sgh)
        {
            TempDirectory directory = null;

            try
            {
                string            group             = sgh.Group;
                SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(this._actDesc.DeployManifest);
                if (this._subStore.CheckGroupInstalled(subscriptionState, this._actDesc.AppId, this._actDesc.AppManifest, group))
                {
                    return(false);
                }
                bool flag = AppDomain.CurrentDomain.ApplicationTrust.DefaultGrantSet.PermissionSet.IsUnrestricted();
                if (!flag && (this._actDesc.AppManifest.FileAssociations.Length > 0))
                {
                    throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_FileExtensionNotSupported"));
                }
                bool flag2 = !this._actDesc.DeployManifest.Deployment.Install;
                if (!flag && flag2)
                {
                    if (this._downloadOptions == null)
                    {
                        this._downloadOptions = new DownloadOptions();
                    }
                    this._downloadOptions.EnforceSizeLimit = true;
                    this._downloadOptions.SizeLimit        = this._subStore.GetSizeLimitInBytesForSemiTrustApps();
                    this._downloadOptions.Size             = this._subStore.GetPrivateSize(this._actDesc.AppId);
                }
                directory = this._subStore.AcquireTempDirectory();
                DownloadManager.DownloadDependencies(subscriptionState, this._actDesc.DeployManifest, this._actDesc.AppManifest, this._actDesc.AppSourceUri, directory.Path, group, blocking ? null : sgh, this._downloadOptions);
                if (!blocking && sgh.CancellationPending)
                {
                    return(true);
                }
                CommitApplicationParams commitParams = new CommitApplicationParams(this._actDesc)
                {
                    CommitApp       = true,
                    AppPayloadPath  = directory.Path,
                    AppManifestPath = null,
                    AppGroup        = group,
                    CommitDeploy    = false
                };
                this._subStore.CommitApplication(ref subscriptionState, commitParams);
            }
            finally
            {
                this.DetachFromGroup(sgh);
                if (directory != null)
                {
                    directory.Dispose();
                }
            }
            return(false);
        }
コード例 #8
0
        private SyncGroupHelper AttachToGroup(string groupName, object userState, out bool created)
        {
            created = false;
            SyncGroupHelper helper = null;

            lock (this._syncGroupMap.SyncRoot)
            {
                helper = (SyncGroupHelper)this._syncGroupMap[groupName];
                if (helper == null)
                {
                    helper = new SyncGroupHelper(groupName, userState, this.asyncOperation, this.progressReporter);
                    this._syncGroupMap[groupName] = helper;
                    created = true;
                }
            }
            return(helper);
        }
コード例 #9
0
 public void CancelAsync(string groupName)
 {
     if (groupName == null)
     {
         this.CancelAsync();
     }
     else
     {
         lock (this._syncGroupMap.SyncRoot)
         {
             SyncGroupHelper helper = (SyncGroupHelper)this._syncGroupMap[groupName];
             if (helper != null)
             {
                 helper.CancelAsync();
             }
         }
     }
 }
コード例 #10
0
 public void CancelAsync(string groupName)
 {
     if (groupName == null)
     {
         this.CancelAsync();
     }
     else
     {
         lock (this._syncGroupMap.SyncRoot)
         {
             SyncGroupHelper local_2 = (SyncGroupHelper)this._syncGroupMap[(object)groupName];
             if (local_2 == null)
             {
                 return;
             }
             local_2.CancelAsync();
         }
     }
 }
 private bool SynchronizeGroupCore(bool blocking, SyncGroupHelper sgh)
 {
     TempDirectory directory = null;
     try
     {
         string group = sgh.Group;
         SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(this._actDesc.DeployManifest);
         if (this._subStore.CheckGroupInstalled(subscriptionState, this._actDesc.AppId, this._actDesc.AppManifest, group))
         {
             return false;
         }
         bool flag = AppDomain.CurrentDomain.ApplicationTrust.DefaultGrantSet.PermissionSet.IsUnrestricted();
         if (!flag && (this._actDesc.AppManifest.FileAssociations.Length > 0))
         {
             throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_FileExtensionNotSupported"));
         }
         bool flag2 = !this._actDesc.DeployManifest.Deployment.Install;
         if (!flag && flag2)
         {
             if (this._downloadOptions == null)
             {
                 this._downloadOptions = new DownloadOptions();
             }
             this._downloadOptions.EnforceSizeLimit = true;
             this._downloadOptions.SizeLimit = this._subStore.GetSizeLimitInBytesForSemiTrustApps();
             this._downloadOptions.Size = this._subStore.GetPrivateSize(this._actDesc.AppId);
         }
         directory = this._subStore.AcquireTempDirectory();
         DownloadManager.DownloadDependencies(subscriptionState, this._actDesc.DeployManifest, this._actDesc.AppManifest, this._actDesc.AppSourceUri, directory.Path, group, blocking ? null : sgh, this._downloadOptions);
         if (!blocking && sgh.CancellationPending)
         {
             return true;
         }
         CommitApplicationParams commitParams = new CommitApplicationParams(this._actDesc) {
             CommitApp = true,
             AppPayloadPath = directory.Path,
             AppManifestPath = null,
             AppGroup = group,
             CommitDeploy = false
         };
         this._subStore.CommitApplication(ref subscriptionState, commitParams);
     }
     finally
     {
         this.DetachFromGroup(sgh);
         if (directory != null)
         {
             directory.Dispose();
         }
     }
     return false;
 }
 private void DetachFromGroup(SyncGroupHelper sgh)
 {
     string group = sgh.Group;
     lock (this._syncGroupMap.SyncRoot)
     {
         this._syncGroupMap.Remove(group);
     }
     sgh.SetComplete();
 }
 private SyncGroupHelper AttachToGroup(string groupName, object userState, out bool created)
 {
     created = false;
     SyncGroupHelper helper = null;
     lock (this._syncGroupMap.SyncRoot)
     {
         helper = (SyncGroupHelper) this._syncGroupMap[groupName];
         if (helper == null)
         {
             helper = new SyncGroupHelper(groupName, userState, this.asyncOperation, this.progressReporter);
             this._syncGroupMap[groupName] = helper;
             created = true;
         }
     }
     return helper;
 }