/// <summary> /// Delete a business object. /// </summary> /// <param name="request">The request parameter object.</param> public WcfResponse Delete(CriteriaRequest request) { var result = new WcfResponse(); try { request = ConvertRequest(request); // unpack criteria data into object object criteria = GetCriteria(request.CriteriaData); // load type for business object var t = Type.GetType(request.TypeName); if (t == null) { throw new InvalidOperationException( string.Format(Resources.ObjectTypeCouldNotBeLoaded, request.TypeName)); } SetContext(request); var factoryInfo = GetMobileFactoryAttribute(t); if (factoryInfo == null) { YYT.DataPortal.Delete(criteria); } else { if (string.IsNullOrEmpty(factoryInfo.DeleteMethodName)) { throw new InvalidOperationException(Resources.DeleteMethodNameNotSpecified); } object f = FactoryLoader.GetFactory(factoryInfo.FactoryTypeName); if (criteria != null) { YYT.Reflection.MethodCaller.CallMethod(f, factoryInfo.DeleteMethodName, criteria); } else { YYT.Reflection.MethodCaller.CallMethod(f, factoryInfo.DeleteMethodName); } } result.GlobalContext = MobileFormatter.Serialize(ApplicationContext.GlobalContext); } catch (YYT.Reflection.CallMethodException ex) { result.ErrorData = new WcfErrorInfo(ex.InnerException); } catch (Exception ex) { result.ErrorData = new WcfErrorInfo(ex); } finally { ClearContext(); } return(ConvertResponse(result)); }
/// <summary> /// Override to convert the request data before it /// is transferred over the network. /// </summary> /// <param name="request">Request object.</param> protected virtual CriteriaRequest ConvertRequest(CriteriaRequest request) { return(request); }
private void SetContext(CriteriaRequest request) { ApplicationContext.SetContext((ContextDictionary)MobileFormatter.Deserialize(request.ClientContext), (ContextDictionary)MobileFormatter.Deserialize(request.GlobalContext)); ApplicationContext.User = (IPrincipal)MobileFormatter.Deserialize(request.Principal); }