10using System.Threading.Tasks;
66 public async
virtual Task<DataPortalResult>
Create(Type objectType,
object criteria,
DataPortalContext context,
bool isSync)
71 var request = GetBaseCriteriaRequest();
72 request.TypeName = AssemblyNameTranslator.GetAssemblyQualifiedName(objectType.AssemblyQualifiedName);
77 request.CriteriaData = SerializationFormatterFactory.GetFormatter(
ApplicationContext).Serialize(criteria);
79 var serialized = SerializationFormatterFactory.GetFormatter(
ApplicationContext).Serialize(request);
80 serialized = await
CallDataPortalServer(serialized,
"create", GetRoutingToken(objectType), isSync);
84 if (response.ErrorData ==
null)
86 var obj = SerializationFormatterFactory.GetFormatter(
ApplicationContext).Deserialize(response.ObjectData);
89 else if (response.ErrorData !=
null)
103 if (result.
Error !=
null)
118 public async
virtual Task<DataPortalResult>
Fetch(Type objectType,
object criteria,
DataPortalContext context,
bool isSync)
123 var request = GetBaseCriteriaRequest();
124 request.TypeName = AssemblyNameTranslator.GetAssemblyQualifiedName(objectType.AssemblyQualifiedName);
129 request.CriteriaData = SerializationFormatterFactory.GetFormatter(
ApplicationContext).Serialize(criteria);
132 var serialized = SerializationFormatterFactory.GetFormatter(
ApplicationContext).Serialize(request);
134 serialized = await
CallDataPortalServer(serialized,
"fetch", GetRoutingToken(objectType), isSync);
138 if (response.ErrorData ==
null)
140 var obj = SerializationFormatterFactory.GetFormatter(
ApplicationContext).Deserialize(response.ObjectData);
143 else if (response.ErrorData !=
null)
157 if (result.
Error !=
null)
176 var request = GetBaseUpdateCriteriaRequest();
177 request.ObjectData = SerializationFormatterFactory.GetFormatter(
ApplicationContext).Serialize(obj);
180 var serialized = SerializationFormatterFactory.GetFormatter(
ApplicationContext).Serialize(request);
182 serialized = await
CallDataPortalServer(serialized,
"update", GetRoutingToken(obj.GetType()), isSync);
186 if (response.ErrorData ==
null)
188 var newobj = SerializationFormatterFactory.GetFormatter(
ApplicationContext).Deserialize(response.ObjectData);
191 else if (response.ErrorData !=
null)
205 if (result.
Error !=
null)
226 var request = GetBaseCriteriaRequest();
227 request.TypeName = AssemblyNameTranslator.GetAssemblyQualifiedName(objectType.AssemblyQualifiedName);
232 request.CriteriaData = SerializationFormatterFactory.GetFormatter(
ApplicationContext).Serialize(criteria);
235 var serialized = SerializationFormatterFactory.GetFormatter(
ApplicationContext).Serialize(request);
237 serialized = await
CallDataPortalServer(serialized,
"delete", GetRoutingToken(objectType), isSync);
241 if (response.ErrorData ==
null)
245 else if (response.ErrorData !=
null)
259 if (result.
Error !=
null)
303 protected abstract Task<byte[]>
CallDataPortalServer(
byte[] serialized,
string operation,
string routingToken,
bool isSync);
305 private string GetRoutingToken(Type objectType)
307 string result =
null;
323 result.ClientCulture = System.Globalization.CultureInfo.CurrentCulture.Name;
324 result.ClientUICulture = System.Globalization.CultureInfo.CurrentUICulture.Name;
335 result.ClientCulture = Thread.CurrentThread.CurrentCulture.Name;
336 result.ClientUICulture = Thread.CurrentThread.CurrentUICulture.Name;
Provides consistent context information between the client and server DataPortal objects.
object CreateInstanceDI(Type objectType, params object[] parameters)
Creates an object using 'Activator.CreateInstance' using service provider (if one is available) to po...
static string AuthenticationType
Gets the authentication type being used by the CSLA .NET framework.
IPrincipal User
Get or set the current IPrincipal object representing the user's identity.
ContextDictionary ClientContext
Returns the application-specific context data provided by the client.
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.
DataPortalProxy(ApplicationContext applicationContext)
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.
byte[] CriteriaData
Serialized data for the criteria object.
Response message for returning the results of a data portal call.
Request message for updating a business object.
byte[] ObjectData
Serialized object data.
Interface implemented by client-side data portal proxy objects.
Interface to be implemented by any object that supports serialization by the SerializationFormatterFa...