public DataSet ServerProcess(DataSet ds) { if (ds == null) { throw new ArgumentNullException("ds"); } string hash = DataSetDiskCache.ComputeHash(ds); var cachedDs = this.dataSetCache.Get(hash); if (cachedDs != null) { return(cachedDs); } else { var result = this.ServerProcessInternal(ds); if (FetchClimateRequestBuilder.IsProcessingSuccessful(result)) { this.dataSetCache.Add(result); } return(result); } }
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; } }
public ProcessingClientBase() { string appFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); this.dataSetCache = new DataSetDiskCache(System.IO.Path.Combine(appFolder, CacheFolder)); }