Server-side data portal implementation that invokes an object factory rather than directly interacting with the business object.
Inheritance: IDataPortalServer
Esempio n. 1
0
 /// <summary>
 /// Get an existing business object.
 /// </summary>
 /// <param name="objectType">Type of business object to retrieve.</param>
 /// <param name="criteria">Criteria object describing business object.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
 public async Task <DataPortalResult> Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
 {
     try
     {
         context.FactoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(objectType);
         if (context.FactoryInfo == null)
         {
             var dp = new SimpleDataPortal();
             return(await dp.Fetch(objectType, criteria, context, isSync).ConfigureAwait(false));
         }
         else
         {
             var dp = new FactoryDataPortal();
             return(await dp.Fetch(objectType, criteria, context, isSync).ConfigureAwait(false));
         }
     }
     catch (DataPortalException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw DataPortal.NewDataPortalException(
                   "DataPortal.Fetch " + Resources.FailedOnServer,
                   ex, null);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Update a business object.
 /// </summary>
 /// <param name="obj">Business object to update.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 public DataPortalResult Update(object obj, DataPortalContext context)
 {
     try
     {
         context.FactoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(obj.GetType());
         if (context.FactoryInfo == null)
         {
             var dp = new SimpleDataPortal();
             return(dp.Update(obj, context));
         }
         else
         {
             var dp = new FactoryDataPortal();
             return(dp.Update(obj, context));
         }
     }
     catch (DataPortalException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new DataPortalException(
                   "DataPortal.Update " + Resources.FailedOnServer,
                   ex, new DataPortalResult(obj));
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Get an existing business object.
 /// </summary>
 /// <param name="objectType">Type of business object to retrieve.</param>
 /// <param name="criteria">Criteria object describing business object.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context)
 {
     try
     {
         context.FactoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(objectType);
         if (context.FactoryInfo == null)
         {
             var dp = new SimpleDataPortal();
             return(dp.Fetch(objectType, criteria, context));
         }
         else
         {
             var dp = new FactoryDataPortal();
             return(dp.Fetch(objectType, criteria, context));
         }
     }
     catch (DataPortalException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new DataPortalException(
                   "DataPortal.Fetch " + Resources.FailedOnServer,
                   ex, new DataPortalResult());
     }
 }
 /// <summary>
 /// Update a business object.
 /// </summary>
 /// <param name="obj">Business object to update.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
 public async Task <DataPortalResult> Update(object obj, DataPortalContext context, bool isSync)
 {
     try
     {
         context.FactoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(obj.GetType());
         if (context.FactoryInfo == null)
         {
             var dp = new SimpleDataPortal();
             return(await dp.Update(obj, context, isSync));
         }
         else
         {
             var dp = new FactoryDataPortal();
             return(await dp.Update(obj, context, isSync));
         }
     }
     catch (DataPortalException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw DataPortal.NewDataPortalException(
                   "DataPortal.Update " + Resources.FailedOnServer,
                   ex, obj);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Get an existing business object.
 /// </summary>
 /// <param name="objectType">Type of business object to retrieve.</param>
 /// <param name="criteria">Criteria object describing business object.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
 public async Task<DataPortalResult> Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
 {
   try
   {
     context.FactoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(objectType);
     if (context.FactoryInfo == null)
     {
       var dp = new SimpleDataPortal();
       return await dp.Fetch(objectType, criteria, context, isSync);
     }
     else
     {
       var dp = new FactoryDataPortal();
       return await dp.Fetch(objectType, criteria, context, isSync);
     }
   }
   catch (DataPortalException)
   {
     throw;
   }
   catch (Exception ex)
   {
     throw DataPortal.NewDataPortalException(
       "DataPortal.Fetch " + Resources.FailedOnServer,
       ex, null);
   }
 }
Esempio n. 6
0
 /// <summary>
 /// Update a business object.
 /// </summary>
 /// <param name="obj">Business object to update.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
 public async Task<DataPortalResult> Update(object obj, DataPortalContext context, bool isSync)
 {
   try
   {
     context.FactoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(obj.GetType());
     if (context.FactoryInfo == null)
     {
       var dp = new SimpleDataPortal();
       return await dp.Update(obj, context, isSync);
     }
     else
     {
       var dp = new FactoryDataPortal();
       return await dp.Update(obj, context, isSync);
     }
   }
   catch (DataPortalException)
   {
     throw;
   }
   catch (Exception ex)
   {
     throw DataPortal.NewDataPortalException(
       "DataPortal.Update " + Resources.FailedOnServer,
       ex, obj);
   }
 }
Esempio n. 7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="applicationContext"></param>
 /// <param name="simpleDataPortal"></param>
 /// <param name="factoryDataPortal"></param>
 public DataPortalSelector(ApplicationContext applicationContext, SimpleDataPortal simpleDataPortal, FactoryDataPortal factoryDataPortal)
 {
   ApplicationContext = applicationContext;
   SimpleDataPortal = simpleDataPortal;
   FactoryDataPortal = factoryDataPortal;
 }
Esempio n. 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="simpleDataPortal"></param>
 /// <param name="factoryDataPortal"></param>
 public DataPortalSelector(SimpleDataPortal simpleDataPortal, FactoryDataPortal factoryDataPortal)
 {
     SimpleDataPortal  = simpleDataPortal;
     FactoryDataPortal = factoryDataPortal;
 }