Beispiel #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="DataPortalContext" /> object passed to the server.</param>
        /// <returns></returns>
        public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context)
        {
            var obj = Fetch(objectType, criteria);

            // return the populated business object as a result
            return new DataPortalResult(obj);
        }
Beispiel #2
0
        /// <summary>
        /// Update a business object.
        /// </summary>
        /// <param name="obj">Business object to update.</param>
        /// <param name="context">
        /// <see cref="DataPortalContext" /> object passed to the server.
        /// </param>
        public DataPortalResult Update(object obj, DataPortalContext context)
        {
            try
            {
                SetContext(context);

                var portal = new FinalDataPortal();
                var result = portal.Update(obj, context);

                return result;
            }
            finally
            {
                ClearContext(context);
            }
        }
Beispiel #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="DataPortalContext" /> object passed to the server.</param>
        /// <returns></returns>
        public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context)
        {
            try
            {
                SetContext(context);

                var portal = new FinalDataPortal();
                var result = portal.Fetch(objectType, criteria, context);

                return result;
            }
            finally
            {
                ClearContext(context);
            }
        }
Beispiel #4
0
        private static void SetContext(DataPortalContext context)
        {
            // set the app context to the value we got from the
            // client
            DistributionContext.ClientContextItem.Value = context.ClientContext;
            DistributionContext.GlobalContextItem.Value = context.GlobalContext;

            // set the thread's culture to match the client
            Thread.CurrentThread.CurrentCulture   = new CultureInfo(context.ClientCulture);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(context.ClientUICulture);

            // We expect the some Principal object
            if (context.Principal == null)
            {
                System.Security.SecurityException ex =
                    new System.Security.SecurityException(
                        "Resources.BusinessPrincipalException" + " Nothing");
                ex.Action = System.Security.Permissions.SecurityAction.Demand;
                throw ex;
            }

            RafyEnvironment.Principal = context.Principal;
        }
Beispiel #5
0
        /// <summary>
        /// Update a business object.
        /// </summary>
        /// <param name="obj">Business object to update.</param>
        /// <param name="context">
        /// <see cref="DataPortalContext" /> object passed to the server.
        /// </param>
        public DataPortalResult Update(object obj, DataPortalContext context)
        {
            Update(obj);

            return(new DataPortalResult(obj));
        }
Beispiel #6
0
 private static void ClearContext(DataPortalContext context)
 {
     DistributionContext.ClientContextItem.Value = null;
     DistributionContext.GlobalContextItem.Value = null;
     RafyEnvironment.Principal = null;
 }
Beispiel #7
0
        /// <summary>
        /// Update a business object.
        /// </summary>
        /// <param name="obj">Business object to update.</param>
        /// <param name="context">
        /// <see cref="DataPortalContext" /> object passed to the server.
        /// </param>
        public DataPortalResult Update(object obj, DataPortalContext context)
        {
            Update(obj);

            return new DataPortalResult(obj);
        }
Beispiel #8
0
 private static void ClearContext(DataPortalContext context)
 {
     DistributionContext.Clear();
     RafyEnvironment.Principal = null;
 }
Beispiel #9
0
        private static void SetContext(DataPortalContext context)
        {
            // set the app context to the value we got from the
            // client
            DistributionContext.SetClientContext(context.ClientContext);
            DistributionContext.SetGlobalContext(context.GlobalContext);

            // set the thread's culture to match the client
            Thread.CurrentThread.CurrentCulture = new CultureInfo(context.ClientCulture);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(context.ClientUICulture);

            // We expect the some Principal object
            if (context.Principal == null)
            {
                System.Security.SecurityException ex =
                  new System.Security.SecurityException(
                    "Resources.BusinessPrincipalException" + " Nothing");
                ex.Action = System.Security.Permissions.SecurityAction.Demand;
                throw ex;
            }

            RafyEnvironment.Principal = context.Principal;
        }
Beispiel #10
0
 private static void ClearContext(DataPortalContext context)
 {
     DistributionContext.Clear();
     RafyEnvironment.Principal = null;
 }
Beispiel #11
0
        /// <summary>
        /// Creates the data portal context.
        /// </summary>
        /// <returns></returns>
        private static DataPortalContext CreateDataPortalContext()
        {
            var res = new DataPortalContext();

            res.Principal = RafyEnvironment.Principal;
            res.ClientCulture = Thread.CurrentThread.CurrentCulture.Name;
            res.ClientUICulture = Thread.CurrentThread.CurrentUICulture.Name;
            res.ClientContext = DistributionContext.GetClientContext();
            res.GlobalContext = DistributionContext.GetGlobalContext();

            return res;
        }