示例#1
0
        /// <summary>
        /// 判断是否存在
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="folderId">文件夹主键</param>
        /// <param name="fileName">文件名</param>
        /// <returns>存在</returns>
        public bool Exists(BaseUserInfo userInfo, string folderId, string fileName)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif

            // 加强安全验证防止未授权匿名调用
#if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
#endif

            bool returnValue = false;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseFileManager fileManager = new BaseFileManager(dbHelper, userInfo);
                    //returnValue = fileManager.Exists(new KeyValuePair<string, object>(BaseFileEntity.FieldFolderId, folderId), new KeyValuePair<string, object>(BaseFileEntity.FieldFileName, fileName));
                    //加入删除状态为0的条件
                    List <KeyValuePair <string, object> > parametersList = new List <KeyValuePair <string, object> >();
                    parametersList.Add(new KeyValuePair <string, object>(BaseFileEntity.FieldFolderId, folderId));
                    parametersList.Add(new KeyValuePair <string, object>(BaseFileEntity.FieldFileName, fileName));
                    parametersList.Add(new KeyValuePair <string, object>(BaseFileEntity.FieldDeletionStateCode, 0));
                    returnValue = fileManager.Exists(parametersList);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.FileService_Exists, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif

            return(returnValue);
        }
示例#2
0
        /// <summary>
        /// 判断是否存在
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="folderId">文件夹主键</param>
        /// <param name="fileName">文件名</param>
        /// <returns>存在</returns>
        public bool Exists(BaseUserInfo userInfo, string folderId, string fileName)
        {
            bool result = false;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseFileManager(dbHelper, userInfo);
                //result = fileManager.Exists(new KeyValuePair<string, object>(BaseFileEntity.FieldFolderId, folderId), new KeyValuePair<string, object>(BaseFileEntity.FieldFileName, fileName));
                //加入删除状态为0的条件
                List <KeyValuePair <string, object> > parametersList = new List <KeyValuePair <string, object> >();
                parametersList.Add(new KeyValuePair <string, object>(BaseFileEntity.FieldFolderId, folderId));
                parametersList.Add(new KeyValuePair <string, object>(BaseFileEntity.FieldFileName, fileName));
                parametersList.Add(new KeyValuePair <string, object>(BaseFileEntity.FieldDeletionStateCode, 0));
                result = manager.Exists(parametersList);
            });

            return(result);
        }