public BizLogicMsg CommitUpdate(EntityObject_MCE_D_MCE_TYPE updateBaseEntity, EntityObject_[] saveDetailEntities, EntityObject_[] updateDetailEntities, EntityObject_[] deleteDetailEntities)
        {
            if (LocalMode)
            {
                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            SystemLogic.Proxy.AuditEdit(updateBaseEntity);
                            HelperObject_MCE_D_MCE_TYPE.Update(updateBaseEntity, transaction);

                            //平台自动生成代码
                            foreach (EntityObject_ obj in saveDetailEntities)
                            {
                                obj. = updateBaseEntity.ID;
                                SystemLogic.Proxy.AuditAdd(obj);
                                HelperObject_.Save(obj, transaction);
                            }
                            foreach (EntityObject_ obj in updateDetailEntities)
                            {
                                SystemLogic.Proxy.AuditEdit(obj);
                                HelperObject_.Update(obj, transaction);
                            }
                            foreach (EntityObject_ obj in deleteDetailEntities)
                            {
                                HelperObject_.Delete(obj, transaction);
                            }
                            PostSave(updateBaseEntity, transaction);
                            transaction.Commit();
                        }
                        catch (Exception expt)
                        {
                            transaction.Rollback();
                            msg = new BizLogicMsg(false, expt.Message);
                            Error(expt);
                        }
                        finally
                        {
                            IDALProvider.IDAL.PushConnection(connection);
                        }
                    }
                }
                return(msg);
            }
            else
            {
                using (ServiceManager <ServiceContract_MCE_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri))
                {
                    return(smgr.Service.CommitUpdate(updateBaseEntity, saveDetailEntities, updateDetailEntities, deleteDetailEntities));
                }
            }
        }
 public int UpdateByTrans(EntityObject_MCE_D_MCE_TYPE obj, IDbTransaction transaction)
 {
     if (LocalMode)
     {
         SystemLogic.Proxy.AuditEdit(obj);
         return(HelperObject_MCE_D_MCE_TYPE.Update(obj, transaction));
         //平台自动生成代码
     }
     else
     {
         throw new InvalidConstraintException();
     }
 }
 public BizLogicMsg UndoAudit(EntityObject_MCE_D_MCE_TYPE obj)
 {
     if (LocalMode)
     {
         BizLogicMsg msg = new BizLogicMsg();
         using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
         {
             using (IDbTransaction transaction = connection.BeginTransaction())
             {
                 try
                 {
                     SystemLogic.Proxy.AuditUndoAudit(obj);
                     int amount = HelperObject_MCE_D_MCE_TYPE.Update(obj, transaction);
                     //平台自动生成代码
                     PostUndoAudit(obj, transaction);
                     //执行撤回操作
                     msg = SystemLogic.Proxy.BillUndoAudit(obj, transaction);
                     if (!msg.Succeed)
                     {
                         throw new Exception(msg.Message);
                     }
                     transaction.Commit();
                 }
                 catch (Exception expt)
                 {
                     SystemLogic.Proxy.AuditState(obj, Ipedf.Common.数据状态.已审核);
                     transaction.Rollback();
                     msg = new BizLogicMsg(false, expt.Message);
                     Error(expt);
                 }
                 finally
                 {
                     IDALProvider.IDAL.PushConnection(connection);
                 }
             }
         }
         return(msg);
     }
     else
     {
         using (ServiceManager <ServiceContract_MCE_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri))
         {
             return(smgr.Service.UndoAudit(obj));
         }
     }
 }
        public BizLogicMsg BatchUpdate(EntityObject_MCE_D_MCE_TYPE[] objs)
        {
            if (LocalMode)
            {
                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            foreach (EntityObject_MCE_D_MCE_TYPE obj in objs)
                            {
                                SystemLogic.Proxy.AuditEdit(obj);
                            }
                            int amount = 0;

                            //平台自动生成代码
                            foreach (EntityObject_MCE_D_MCE_TYPE obj in objs)
                            {
                                amount += HelperObject_MCE_D_MCE_TYPE.Update(obj, transaction);
                            }
                            transaction.Commit();
                        }
                        catch (Exception expt)
                        {
                            transaction.Rollback();
                            msg = new BizLogicMsg(false, expt.Message);
                            Error(expt);
                        }
                        finally
                        {
                            IDALProvider.IDAL.PushConnection(connection);
                        }
                    }
                }
                return(msg);
            }
            else
            {
                using (ServiceManager <ServiceContract_MCE_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri))
                {
                    return(smgr.Service.BatchUpdate(objs));
                }
            }
        }
Ejemplo n.º 5
0
        public BizLogicMsg Save_Ext(JsonMceType jsonMceType)
        {
            if (LocalMode)
            {
                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            EntityObject_MCE_D_MCE_TYPE obj = new EntityObject_MCE_D_MCE_TYPE();

                            obj.CODE      = jsonMceType.code;
                            obj.NAME      = jsonMceType.name;
                            obj.PARENT_ID = jsonMceType.parent_id;
                            obj.STATE     = jsonMceType.state;

                            if (string.IsNullOrEmpty(jsonMceType.id))
                            {
                                obj.CREATE_TIME    = DateTime.Now;
                                obj.CREATE_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;
                                int amount = HelperObject_MCE_D_MCE_TYPE.Save(obj, transaction);
                            }
                            else
                            {
                                obj.ID = jsonMceType.id;
                                int amount = HelperObject_MCE_D_MCE_TYPE.Update(obj, transaction);

                                /*
                                 * CauseObject_MCE_D_TYPE_DEPT cause = new CauseObject_MCE_D_TYPE_DEPT();
                                 * cause.MCE_TYPE_ID = jsonMceType.id;
                                 * int amount1 = HelperObject_MCE_D_TYPE_DEPT.Delete(cause, transaction);
                                 */
                            }

                            /*
                             * if (jsonMceType.listDeptID != null && jsonMceType.listDeptID.Count>0)
                             * {
                             *  foreach (string strDeptID in jsonMceType.listDeptID)
                             *  {
                             *      EntityObject_MCE_D_TYPE_DEPT item = new EntityObject_MCE_D_TYPE_DEPT();
                             *      item.MCE_TYPE_ID =  obj.ID;
                             *      item.DEPT_ID = strDeptID;
                             *      HelperObject_MCE_D_TYPE_DEPT.Save(item, transaction);
                             *  }
                             *
                             * }
                             */

                            //平台自动生成代码

                            transaction.Commit();
                        }
                        catch (Exception expt)
                        {
                            transaction.Rollback();
                            msg = new BizLogicMsg(false, expt.Message);
                            Error(expt);
                        }
                        finally
                        {
                            IDALProvider.IDAL.PushConnection(connection);
                        }
                    }
                }
                return(msg);
            }
            else
            {
                using (ServiceManager <ServiceContract_MCE_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri))
                {
                    return(smgr.Service.Save_Ext(jsonMceType));
                }
            }
        }