Пример #1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="keyValue">主键</param>
        /// <param name="functionEntity">功能信息</param>
        /// <param name="functionSchemeEntity">功能模板信息</param>
        public void SaveEntity(string keyValue, FunctionEntity functionEntity, FunctionSchemeEntity functionSchemeEntity)
        {
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                // 如果是代码开发功能
                if (functionEntity.F_IsSystem == 1)
                {
                    if (!string.IsNullOrEmpty(functionEntity.F_SchemeId))
                    {
                        db.Delete <FunctionSchemeEntity>(t => t.F_Id == functionEntity.F_SchemeId);
                    }
                }
                else
                {
                    #region 模板信息
                    if (string.IsNullOrEmpty(functionEntity.F_SchemeId))
                    {
                        functionSchemeEntity.Create();
                        db.Insert(functionSchemeEntity);
                        functionEntity.F_SchemeId = functionSchemeEntity.F_Id;
                    }
                    else
                    {
                        functionSchemeEntity.Modify(functionEntity.F_SchemeId);
                        db.Update(functionSchemeEntity);
                    }
                    #endregion
                }

                if (string.IsNullOrEmpty(keyValue))
                {
                    functionEntity.Create();
                    db.Insert(functionEntity);
                }
                else
                {
                    functionEntity.Modify(keyValue);
                    db.Update(functionEntity);
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="keyValue">主键</param>
 /// <param name="functionEntity">功能信息</param>
 /// <param name="functionSchemeEntity">功能模板信息</param>
 public void SaveEntity(string keyValue, FunctionEntity functionEntity, FunctionSchemeEntity functionSchemeEntity)
 {
     try
     {
         functionSerivce.SaveEntity(keyValue, functionEntity, functionSchemeEntity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }