1#if !NETSTANDARD2_0 && !NET5_0
10using System.ServiceModel;
11using System.Threading.Tasks;
23 private static System.ServiceModel.Channels.Binding _defaultBinding;
24 private const int TimeoutInMinutes = 10;
25 private static string _defaultEndPoint =
"WcfDataPortal";
35 if (_defaultBinding ==
null)
37 _defaultBinding =
new WSHttpBinding();
38 WSHttpBinding binding = (WSHttpBinding)_defaultBinding;
39 binding.MaxReceivedMessageSize =
int.MaxValue;
40 binding.ReaderQuotas =
new System.Xml.XmlDictionaryReaderQuotas()
42 MaxBytesPerRead =
int.MaxValue,
43 MaxDepth =
int.MaxValue,
44 MaxArrayLength =
int.MaxValue,
45 MaxStringContentLength =
int.MaxValue,
46 MaxNameTableCharCount =
int.MaxValue
49 binding.ReceiveTimeout = TimeSpan.FromMinutes(TimeoutInMinutes);
50 binding.SendTimeout = TimeSpan.FromMinutes(TimeoutInMinutes);
51 binding.OpenTimeout = TimeSpan.FromMinutes(TimeoutInMinutes);
53 return _defaultBinding;
55 set { _defaultBinding = value; }
67 get {
return ApplicationContext.DataPortalUrlString; }
68 set { ApplicationContext.DataPortalUrlString = value; }
77 get {
return _defaultEndPoint; }
78 set { _defaultEndPoint = value; }
118 public System.ServiceModel.Channels.Binding
Binding {
get;
protected set; }
144 if (!
string.IsNullOrEmpty(ApplicationContext.DataPortalUrlString))
145 return new ChannelFactory<IWcfPortal>(
Binding,
new EndpointAddress(ApplicationContext.DataPortalUrl));
147 return new ChannelFactory<IWcfPortal>(
EndPoint);
160 return cf.CreateChannel();
180 var request =
new CreateRequest(objectType, criteria, context);
182 response = proxy.Create(request);
184 response = await proxy.CreateAsync(request);
193 object result = response.
Result;
194 if (result is Exception)
195 throw (Exception)result;
209#pragma warning disable 1998
211#pragma warning restore 1998
218 var request =
new FetchRequest(objectType, criteria, context);
220 response = proxy.Fetch(request);
222 response = await proxy.FetchAsync(request);
231 object result = response.
Result;
232 if (result is Exception)
233 throw (Exception)result;
246#pragma warning disable 1998
248#pragma warning restore 1998
257 response = proxy.Update(request);
259 response = await proxy.UpdateAsync(request);
268 object result = response.
Result;
269 if (result is Exception)
270 throw (Exception)result;
284#pragma warning disable 1998
286#pragma warning restore 1998
293 var request =
new DeleteRequest(objectType, criteria, context);
295 response = proxy.Delete(request);
297 response = await proxy.DeleteAsync(request);
306 object result = response.
Result;
307 if (result is Exception)
308 throw (Exception)result;
Implements a data portal proxy to relay data portal calls to a remote application server by using WCF...
WcfProxy(string dataPortalUrl)
Creates an instance of the object, initializing it to use the supplied URL and DefaultBinding values.
static string DefaultUrl
Gets or sets the default URL address for the data portal server.
bool IsServerRemote
Gets a value indicating whether the data portal is hosted on a remote server.
async Task< DataPortalResult > Create(Type objectType, object criteria, DataPortalContext context, bool isSync)
Called by DataPortal to create a new business object.
WcfProxy()
Creates an instance of the object, initializing it to use the DefaultUrl and DefaultBinding values.
async Task< DataPortalResult > Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
Called by DataPortal to load an existing business object.
async Task< DataPortalResult > Update(object obj, DataPortalContext context, bool isSync)
Called by DataPortal to update a business object.
string EndPoint
Gets the WCF endpoint name for the data portal server used by this proxy instance.
System.ServiceModel.Channels.Binding Binding
Gets the binding object used by this proxy instance.
string DataPortalUrl
Gets the URL address for the data portal server used by this proxy instance.
virtual ChannelFactory< IWcfPortal > GetChannelFactory()
Returns an instance of the channel factory used by GetProxy() to create the WCF proxy object.
static System.ServiceModel.Channels.Binding DefaultBinding
Gets or sets the default binding used to initialize future instances of WcfProxy.
virtual IWcfPortal GetProxy(ChannelFactory< IWcfPortal > cf)
Returns the WCF proxy object used for communication with the data portal server.
static string DefaultEndPoint
Gets or sets the default WCF endpoint name for the data portal server.
async Task< DataPortalResult > Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
Called by DataPortal to delete a business object.
DataPortalResult defines the results of DataPortal operation.
Provides consistent context information between the client and server DataPortal objects.
Request message for creating a new business object.
Request message for deleting a business object.
Request message for retrieving an existing business object.
Request message for updating a business object.
Response message for returning the results of a data portal call.
object Result
Busines object or exception return as result of service call.
Interface implemented by client-side data portal proxy objects.