10using System.Threading.Tasks;
41 public string DataPortalUrl {
get;
protected set; } = ApplicationContext.DataPortalUrlString;
53 public async
virtual Task<DataPortalResult>
Create(Type objectType,
object criteria,
DataPortalContext context,
bool isSync)
58 var request = GetBaseCriteriaRequest();
59 request.TypeName = AssemblyNameTranslator.GetAssemblyQualifiedName(objectType.AssemblyQualifiedName);
64 request.CriteriaData = SerializationFormatterFactory.GetFormatter().Serialize(criteria);
66 var serialized = SerializationFormatterFactory.GetFormatter().Serialize(request);
67 serialized = await
CallDataPortalServer(serialized,
"create", GetRoutingToken(objectType), isSync);
68 var response = (
DataPortalResponse)SerializationFormatterFactory.GetFormatter().Deserialize(serialized);
71 var globalContext = (
ContextDictionary)SerializationFormatterFactory.GetFormatter().Deserialize(response.GlobalContext);
72 if (response.ErrorData ==
null)
74 var obj = SerializationFormatterFactory.GetFormatter().Deserialize(response.ObjectData);
77 else if (response.ErrorData !=
null)
91 if (result.
Error !=
null)
106 public async
virtual Task<DataPortalResult>
Fetch(Type objectType,
object criteria,
DataPortalContext context,
bool isSync)
111 var request = GetBaseCriteriaRequest();
112 request.TypeName = AssemblyNameTranslator.GetAssemblyQualifiedName(objectType.AssemblyQualifiedName);
117 request.CriteriaData = SerializationFormatterFactory.GetFormatter().Serialize(criteria);
120 var serialized = SerializationFormatterFactory.GetFormatter().Serialize(request);
122 serialized = await
CallDataPortalServer(serialized,
"fetch", GetRoutingToken(objectType), isSync);
124 var response = (
DataPortalResponse)SerializationFormatterFactory.GetFormatter().Deserialize(serialized);
126 var globalContext = (
ContextDictionary)SerializationFormatterFactory.GetFormatter().Deserialize(response.GlobalContext);
127 if (response.ErrorData ==
null)
129 var obj = SerializationFormatterFactory.GetFormatter().Deserialize(response.ObjectData);
132 else if (response.ErrorData !=
null)
146 if (result.
Error !=
null)
165 var request = GetBaseUpdateCriteriaRequest();
166 request.ObjectData = SerializationFormatterFactory.GetFormatter().Serialize(obj);
169 var serialized = SerializationFormatterFactory.GetFormatter().Serialize(request);
171 serialized = await
CallDataPortalServer(serialized,
"update", GetRoutingToken(obj.GetType()), isSync);
173 var response = (
DataPortalResponse)SerializationFormatterFactory.GetFormatter().Deserialize(serialized);
175 var globalContext = (
ContextDictionary)SerializationFormatterFactory.GetFormatter().Deserialize(response.GlobalContext);
176 if (response.ErrorData ==
null)
178 var newobj = SerializationFormatterFactory.GetFormatter().Deserialize(response.ObjectData);
181 else if (response.ErrorData !=
null)
195 if (result.
Error !=
null)
216 var request = GetBaseCriteriaRequest();
217 request.TypeName = AssemblyNameTranslator.GetAssemblyQualifiedName(objectType.AssemblyQualifiedName);
222 request.CriteriaData = SerializationFormatterFactory.GetFormatter().Serialize(criteria);
225 var serialized = SerializationFormatterFactory.GetFormatter().Serialize(request);
227 serialized = await
CallDataPortalServer(serialized,
"delete", GetRoutingToken(objectType), isSync);
229 var response = (
DataPortalResponse)SerializationFormatterFactory.GetFormatter().Deserialize(serialized);
231 var globalContext = (
ContextDictionary)SerializationFormatterFactory.GetFormatter().Deserialize(response.GlobalContext);
232 if (response.ErrorData ==
null)
236 else if (response.ErrorData !=
null)
250 if (result.
Error !=
null)
294 protected abstract Task<byte[]>
CallDataPortalServer(
byte[] serialized,
string operation,
string routingToken,
bool isSync);
296 private string GetRoutingToken(Type objectType)
298 string result =
null;
312 ClientContext = SerializationFormatterFactory.GetFormatter().Serialize(ApplicationContext.ClientContext),
313#pragma warning disable CS0618
314 GlobalContext = SerializationFormatterFactory.GetFormatter().Serialize(ApplicationContext.GlobalContext),
315#pragma warning restore CS0618
316 Principal = SerializationFormatterFactory.GetFormatter()
317 .Serialize(ApplicationContext.AuthenticationType ==
"Windows" ?
null : ApplicationContext.User),
318 ClientCulture = System.Globalization.CultureInfo.CurrentCulture.Name,
319 ClientUICulture = System.Globalization.CultureInfo.CurrentUICulture.Name
328 ClientContext = SerializationFormatterFactory.GetFormatter().Serialize(ApplicationContext.ClientContext),
329#pragma warning disable CS0618
330 GlobalContext = SerializationFormatterFactory.GetFormatter().Serialize(ApplicationContext.GlobalContext),
331#pragma warning restore CS0618
332 Principal = SerializationFormatterFactory.GetFormatter()
333 .Serialize(ApplicationContext.AuthenticationType ==
"Windows" ?
null : ApplicationContext.User),
334 ClientCulture = Thread.CurrentThread.CurrentCulture.Name,
335 ClientUICulture = Thread.CurrentThread.CurrentUICulture.Name
Dictionary type that is serializable with the SerializationFormatterFactory.GetFormatter().
Implements a data portal proxy to relay data portal calls to a remote application server.
virtual async Task< DataPortalResult > Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
Called by DataPortal to delete a business object.
virtual async Task< DataPortalResult > Update(object obj, DataPortalContext context, bool isSync)
Called by DataPortal to update a business object.
virtual async Task< DataPortalResult > Create(Type objectType, object criteria, DataPortalContext context, bool isSync)
Called by DataPortal to create a new business object.
virtual int Timeout
Gets or sets the Client timeout in milliseconds (0 uses default timeout).
virtual bool IsServerRemote
Gets a value indicating whether the data portal is hosted on a remote server.
string DataPortalUrl
Gets the URL address for the data portal server used by this proxy instance.
virtual async Task< DataPortalResult > Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
Called by DataPortal to load an existing business object.
abstract Task< byte[]> CallDataPortalServer(byte[] serialized, string operation, string routingToken, bool isSync)
Override this method with implementation of sending and receiving of data to the server Returns seria...
virtual CriteriaRequest ConvertRequest(CriteriaRequest request)
Override this method to manipulate the message request data sent to the server.
virtual UpdateRequest ConvertRequest(UpdateRequest request)
Override this method to manipulate the message request data sent to the server.
virtual DataPortalResponse ConvertResponse(DataPortalResponse response)
Override this method to manipulate the message request data returned from the server.
Class used as a wrapper for criteria based requests that use primitives
This exception is returned for any errors occurring during the server-side DataPortal invocation.
DataPortalResult defines the results of DataPortal operation.
Exception Error
Error that occurred during the DataPotal call.
Specifies a routing tag for use by the server-side data portal.
Provides consistent context information between the client and server DataPortal objects.
Message sent to the WCF data portal.
Response message for returning the results of a data portal call.
Request message for updating a business object.
Interface implemented by client-side data portal proxy objects.
Interface to be implemented by any object that supports serialization by the SerializationFormatterFa...