protected override DataSet ServerProcessInternal(DataSet ds) { if (serviceUri == "(local)") return LocalProcess(ds); string hash = DataSetDiskCache.ComputeHash(ds); DataSet proxyDataSet = null; // Creating new DataSet at the service. // TODO: fix following: try { try { proxyDataSet = ProxyDataSet.CreateProxySync(taskQueue, ServicePort, "msds:memory", false, 10 * 60 * 1000); } catch (CommunicationObjectFaultedException) { //Connection to server closed. //Recreate service port and try again. if (proxyDataSet != null && !proxyDataSet.IsDisposed) proxyDataSet.Dispose(); this._servicePort = null; proxyDataSet = ProxyDataSet.CreateProxySync(taskQueue, ServicePort, "msds:memory", false, 10 * 60 * 1000); } AutoResetEvent completed = new AutoResetEvent(false); OnCommittedHandler onCommitted = new OnCommittedHandler(completed, OnDataSetCommitted); proxyDataSet.Committed += onCommitted.Handler; proxyDataSet.IsAutocommitEnabled = false; FetchClimateRequestBuilder.CopyRequestedDataSet(ds, proxyDataSet, false); proxyDataSet.Metadata[Namings.metadataNameHash] = hash; proxyDataSet.Commit(); if (proxyDataSet.HasChanges) proxyDataSet.Commit(); completed.WaitOne(); proxyDataSet.IsAutocommitEnabled = true; return proxyDataSet; } catch { if (proxyDataSet != null && !proxyDataSet.IsDisposed) proxyDataSet.Dispose(); throw; } }
private void OnDataSetCommitted(DataSetCommittedEventArgs e, OnCommittedHandler handler) { if ((e.Changes.ChangesetSource & ChangesetSource.Remote) == 0) { return; // we're waiting for remote changes } var ds = e.DataSet; if (FetchClimateRequestBuilder.IsProcessingSuccessful(ds) || FetchClimateRequestBuilder.IsProcessingFailed(ds)) { ds.Committed -= handler.Handler; handler.Completed.Set(); } }