Example #1
0
        public DataPortalResult Create(
            Type objectType, object criteria, DataPortalContext context)
        {
            SimpleDataPortal portal = new SimpleDataPortal();

            return(portal.Create(objectType, criteria, context));
        }
Example #2
0
        public DataPortalResult Delete(object criteria, DataPortalContext context)
        {
            DataPortalResult result;

            using (TransactionScope tr = new TransactionScope())
            {
                SimpleDataPortal portal = new SimpleDataPortal();
                result = portal.Delete(criteria, context);
                tr.Complete();
            }
            return(result);
        }
Example #3
0
        public DataPortalResult Update(object obj, DataPortalContext context)
        {
            DataPortalResult result;

            using (TransactionScope tr = new TransactionScope())
            {
                SimpleDataPortal portal = new SimpleDataPortal();
                result = portal.Update(obj, context);
                tr.Complete();
            }
            return(result);
        }
Example #4
0
        public DataPortalResult Create(
            System.Type objectType, object criteria, DataPortalContext context)
        {
            DataPortalResult result;

            using (TransactionScope tr = new TransactionScope())
            {
                SimpleDataPortal portal = new SimpleDataPortal();
                result = portal.Create(objectType, criteria, context);
                tr.Complete();
            }
            return(result);
        }
Example #5
0
        public DataPortalResult Create(
            Type objectType, object criteria, DataPortalContext context)
        {
            try
            {
                SetContext(context);

                DataPortalResult result;

                MethodInfo method = MethodCaller.GetMethod(
                    objectType, "DataPortal_Create", criteria);

                IDataPortalServer portal;
                switch (TransactionalType(method))
                {
                case TransactionalTypes.EnterpriseServices:
                    portal = new ServicedDataPortal();
                    try
                    {
                        result = portal.Create(objectType, criteria, context);
                    }
                    finally
                    {
                        ((ServicedDataPortal)portal).Dispose();
                    }

                    break;

                case TransactionalTypes.TransactionScope:

                    portal = new TransactionalDataPortal();
                    result = portal.Create(objectType, criteria, context);

                    break;

                default:
                    portal = new SimpleDataPortal();
                    result = portal.Create(objectType, criteria, context);
                    break;
                }
                return(result);
            }
            finally
            {
                ClearContext(context);
            }
        }
Example #6
0
        public DataPortalResult Update(object obj, DataPortalContext context)
        {
            try
            {
                SetContext(context);

                DataPortalResult result;

                MethodInfo method;
                string     methodName;
                if (obj is CommandBase)
                {
                    methodName = "DataPortal_Execute";
                }
                else if (obj is Core.BusinessBase)
                {
                    Core.BusinessBase tmp = (Core.BusinessBase)obj;
                    if (tmp.IsDeleted)
                    {
                        methodName = "DataPortal_DeleteSelf";
                    }
                    else
                    if (tmp.IsNew)
                    {
                        methodName = "DataPortal_Insert";
                    }
                    else
                    {
                        methodName = "DataPortal_Update";
                    }
                }
                else
                {
                    methodName = "DataPortal_Update";
                }

                method = MethodCaller.GetMethod(obj.GetType(), methodName);

                IDataPortalServer portal;
                switch (TransactionalType(method))
                {
                case TransactionalTypes.EnterpriseServices:
                    portal = new ServicedDataPortal();
                    try
                    {
                        result = portal.Update(obj, context);
                    }
                    finally
                    {
                        ((ServicedDataPortal)portal).Dispose();
                    }
                    break;

                case TransactionalTypes.TransactionScope:
                    portal = new TransactionalDataPortal();
                    result = portal.Update(obj, context);
                    break;

                default:
                    portal = new SimpleDataPortal();
                    result = portal.Update(obj, context);
                    break;
                }
                return(result);
            }
            finally
            {
                ClearContext(context);
            }
        }
Example #7
0
        public DataPortalResult Delete(object criteria, DataPortalContext context)
        {
            SimpleDataPortal portal = new SimpleDataPortal();

            return(portal.Delete(criteria, context));
        }
Example #8
0
        public DataPortalResult Update(object obj, DataPortalContext context)
        {
            SimpleDataPortal portal = new SimpleDataPortal();

            return(portal.Update(obj, context));
        }