Пример #1
0
        /// <summary>
        /// 批量设置默认角色
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="userIds"></param>
        /// <param name="roleId"></param>
        /// <returns>影响行数</returns>
        public int BatchSetDefaultRole(BaseUserInfo userInfo, string[] userIds, string roleId)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    returnValue = userManager.SetProperty(userIds, new KeyValuePair <string, object>(BaseUserEntity.FieldRoleId, roleId));

                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, 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="userId">员工主键</param>
        /// <returns>主键数组</returns>
        public string[] GetUserRoleIds(BaseUserInfo userInfo, string userId)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            string[] returnValue = null;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    returnValue = userManager.GetAllRoleIds(userId);
                    // returnValue = userRoleManager.GetRoleIds(userId);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, 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);
        }
Пример #3
0
        /// <summary>
        /// 获取员工列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTable(BaseUserInfo userInfo)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            DataTable dataTable = new DataTable(BaseStaffEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    dataTable           = staffManager.GetDataTable(new KeyValuePair <string, object>(BaseStaffEntity.FieldDeletionStateCode, 0), BaseStaffEntity.FieldSortCode);
                    dataTable.TableName = BaseStaffEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_GetDataTable, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return(dataTable);
        }
Пример #4
0
        /// <summary>
        /// 同步省市区数据
        /// </summary>
        /// <param name="delete"></param>
        /// <returns></returns>
        public static int SynchronousArea(bool delete = false)
        {
            int result = 0;

            if (!System.IO.File.Exists(SqLiteDb))
            {
                return(result);
            }

            DateTime?modifiedOn = new DateTime(2014, 01, 01);

            string dbConnection = "Data Source={StartupPath}/DataBase/STO.Bill.db;Pooling=true;FailIfMissing=false;Password=ZTO20149988";

            dbConnection = dbConnection.Replace("{StartupPath}", System.Windows.Forms.Application.StartupPath);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(CurrentDbType.SQLite, dbConnection))
            {
                BaseParameterManager parameterManager = new BaseParameterManager(dbHelper, BaseSystemInfo.UserInfo, BaseParameterEntity.TableName);
                var tableName = BaseAreaEntity.TableName;

                if (!delete)
                {
                    var synchronous = parameterManager.GetParameter(BaseParameterEntity.TableName, "System", tableName, "Synchronous");
                    if (!string.IsNullOrEmpty(synchronous))
                    {
                        modifiedOn = DateTime.Parse(synchronous);
                    }
                }

                if (delete)
                {
                    dbHelper.ExecuteNonQuery("DELETE FROM " + tableName);
                }
                result = SynchronousTable("UserCenter", tableName, new string[] { BaseAreaEntity.FieldId }, modifiedOn, "Bill", tableName, 20000, false);
                if (result > 0)
                {
                    parameterManager.SetParameter(BaseParameterEntity.TableName, "System", tableName, "Synchronous", DateTime.Now.ToString(BaseSystemInfo.DateTimeFormat));
                }
            }

            return(result);
        }
Пример #5
0
        /// <summary>
        /// 批量保存
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="dataTable">数据表</param>
        /// <returns>影响行数</returns>
        public int BatchSave(BaseUserInfo userInfo, DataTable dataTable)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif

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

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, dataTable.TableName);
                    returnValue = itemDetailsManager.BatchSave(dataTable);
                    // dataTable = BaseItemDetails.GetDataTableByParent(ParentId);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.ItemDetailsService_BatchSave, 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);
        }
Пример #6
0
        /// <summary>
        /// 获取已审核流程列表
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <param name="categoryCode">单据类型</param>
        /// <param name="categorybillFullName">流程</param>
        /// <param name="searchValue">关键字</param>
        /// <returns></returns>
        public DataTable GetAuditRecord(BaseUserInfo userInfo, string categoryCode, string categorybillFullName = null, string searchValue = null)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            DataTable dataTable = null;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType))
            {
                try
                {
                    dbHelper.Open(WorkFlowDbConnection);
                    BaseWorkFlowCurrentManager workFlowCurrentManager = new BaseWorkFlowCurrentManager(dbHelper, userInfo);
                    dataTable           = workFlowCurrentManager.GetAuditRecord(categoryCode, categorybillFullName, searchValue);
                    dataTable.TableName = BaseWorkFlowCurrentEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return(dataTable);
        }
Пример #7
0
        /// <summary>
        /// 获取工作流主键
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <param name="categoryId">类型主键</param>
        /// <param name="objectId">单据主键</param>
        /// <returns></returns>
        public string GetCurrentId(BaseUserInfo userInfo, string categoryId, string objectId)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType))
            {
                try
                {
                    // 打开数据库
                    dbHelper.Open(WorkFlowDbConnection);
                    BaseWorkFlowCurrentManager workFlowCurrentManager = new BaseWorkFlowCurrentManager(dbHelper, userInfo);
                    returnValue = workFlowCurrentManager.GetCurrentId(categoryId, objectId);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, 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);
        }
Пример #8
0
        public BaseWorkFlowProcessEntity GetEntity(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            BaseWorkFlowProcessEntity workFlowEntity = new BaseWorkFlowProcessEntity();
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType))
            {
                try
                {
                    dbHelper.Open(WorkFlowDbConnection);
                    // 创建实现类
                    BaseWorkFlowProcessManager workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                    workFlowEntity = workFlowManager.GetEntity(id);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return(workFlowEntity);
        }
        /// <summary>
        /// 批量保存
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="dataTable">数据表</param>
        /// <returns>影响行数</returns>
        public int BatchSave(BaseUserInfo userInfo, DataTable dataTable)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType))
            {
                try
                {
                    dbHelper.Open(WorkFlowDbConnection);
                    BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(dbHelper, userInfo);
                    returnValue = workFlowActivityManager.BatchSave(dataTable);
                    // dataTable = Role.GetDataTableByOrganize(organizeId);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, 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);
        }
Пример #10
0
        /// <summary>
        /// 把用户添加到组织机构
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userOrganizeEntity">用户组织机构关系</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        public string AddUserToOrganize(BaseUserInfo userInfo, BaseUserOrganizeEntity userOrganizeEntity, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserOrganizeManager userOrganizeManager = new BaseUserOrganizeManager(dbHelper, userInfo);
                    returnValue   = userOrganizeManager.Add(userOrganizeEntity, out statusCode);
                    statusMessage = userOrganizeManager.GetStateMessage(statusCode);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, 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);
        }
Пример #11
0
        /// <summary>
        /// 删除异常
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>数据表</returns>
        public DataTable Delete(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            DataTable dataTable = new DataTable(BaseExceptionEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseExceptionManager exceptionManager = new BaseExceptionManager(dbHelper, userInfo);
                    exceptionManager.Delete(BaseExceptionEntity.FieldId, new string[] { id });
                    dataTable = exceptionManager.GetDataTable();
                    BaseLogManager.Instance.Add(dbHelper, userInfo, serviceName, AppMessage.ExceptionService_Delete, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return(dataTable);
        }
Пример #12
0
        /// <summary>
        /// 检查在线状态
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="onLineState">用户在线状态</param>
        /// <returns>离线人数</returns>
        public int CheckOnLine(BaseUserInfo userInfo, int onLineState)
        {
            // 写入调试信息
            #if (DEBUG)
            // int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserManager userManager = new BaseUserManager(dbHelper);
                    // 设置为在线状态
                    userManager.OnLine(userInfo.Id, onLineState);
                    returnValue = userManager.CheckOnLine();
                }
                catch (Exception ex)
                {
                    LogUtil.WriteException(ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return(returnValue);
        }
Пример #13
0
        /// <summary>
        /// 获得用户的数据权限范围
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <param name="permissionItemCode">数据权限编号</param>
        /// <returns>数据权限范围</returns>
        public PermissionScope GetUserPermissionScope(BaseUserInfo userInfo, string userId, string permissionItemCode)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            PermissionScope returnValue = PermissionScope.None;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    // 是超级管理员,就不用继续判断权限了
                    BasePermissionScopeManager permissionScopeManager = new BasePermissionScopeManager(dbHelper, userInfo);
                    returnValue = permissionScopeManager.GetUserPermissionScope(userId, permissionItemCode);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.PermissionService_GetUserPermissionScope, 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);
        }
Пример #14
0
        /// <summary>
        /// 查询用户
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="search">查询</param>
        /// <param name="auditStates">有效</param>
        /// <param name="roleIds">用户角色</param>
        /// <returns>数据表</returns>
        public DataTable Search(BaseUserInfo userInfo, string searchValue, string auditStates, string[] roleIds)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            DataTable dataTable = new DataTable(BaseUserEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    dataTable           = userManager.Search(searchValue, roleIds, null, auditStates);
                    dataTable.TableName = BaseUserEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.UserService_Search, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return(dataTable);
        }
Пример #15
0
        /// <summary>
        /// 按日期获取日志(业务)
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="beginDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableApplicationByDate(BaseUserInfo userInfo, string beginDate, string endDate)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            DataTable dataTable = new DataTable(BaseLogEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(BusinessDbConnection);
                    BaseLogManager logManager = new BaseLogManager(dbHelper, userInfo);
                    dataTable           = logManager.GetDataTableByDate(string.Empty, string.Empty, beginDate, endDate);
                    dataTable.TableName = BaseLogEntity.TableName;
                    // 添加访问日志
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.LogService_GetDataTableApplicationByDate, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif
            return(dataTable);
        }
Пример #16
0
        /// <summary>
        /// 按主键数组获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">组织机构主键</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByIds(BaseUserInfo userInfo, string[] ids)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif

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

            DataTable dataTable = new DataTable(BasePermissionItemEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BasePermissionItemManager permissionItem = new BasePermissionItemManager(dbHelper, userInfo);
                    dataTable           = permissionItem.GetDataTable(BasePermissionItemEntity.FieldId, ids, BasePermissionItemEntity.FieldSortCode);
                    dataTable.TableName = BasePermissionItemEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, serviceName, AppMessage.PermissionItemService_GetDataTable, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return(dataTable);
        }
Пример #17
0
        /// <summary>
        /// 批量重置序列
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int Reset(BaseUserInfo userInfo, string[] ids)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            int returnValue = 0;

            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseSequenceManager sequenceManager = new BaseSequenceManager(dbHelper);
                    returnValue = sequenceManager.Reset(ids);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.SequenceService_Reset, 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);
        }
Пример #18
0
        private static void AddLogTask(object param)
        {
            var    tuple         = param as Tuple <string, string, string, string, string, string, string>;
            string systemCode    = tuple.Item1;
            string userId        = tuple.Item2;
            string userName      = tuple.Item3;
            string ipAddress     = tuple.Item4;
            string ipAddressName = tuple.Item5;
            string macAddress    = tuple.Item6;
            string loginStatus   = tuple.Item7;

            BaseLoginLogEntity entity = new BaseLoginLogEntity();

            entity.SystemCode    = systemCode;
            entity.UserId        = userId;
            entity.UserName      = userName;
            entity.IPAddress     = ipAddress;
            entity.IPAddressName = ipAddressName;
            entity.MACAddress    = macAddress;
            entity.LoginStatus   = loginStatus;
            entity.LogLevel      = LoginStatusToLogLevel(loginStatus);
            entity.CreateOn      = DateTime.Now;

            string tableName = GetSplitTableName();

            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.LoginLogDbType, BaseSystemInfo.LoginLogDbConnection))
            {
                BaseLoginLogManager loginLogManager = new BaseLoginLogManager(dbHelper, tableName);
                try
                {
                    // 2015-07-13 把登录日志无法正常写入的,进行日志记录
                    loginLogManager.Add(entity, false, false);
                }
                catch (System.Exception ex)
                {
                    FileUtil.WriteMessage("AddLogTask: 异常信息:" + ex.Message
                                          + System.Environment.NewLine + "错误源:" + ex.Source
                                          + System.Environment.NewLine + "堆栈信息:" + ex.StackTrace, System.Web.HttpContext.Current.Server.MapPath("~/Log/") + "Log" + DateTime.Now.ToString(BaseSystemInfo.DateFormat) + ".txt");
                }
            }
        }
Пример #19
0
        /// <summary>
        /// 验证用户数字签名密码
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="signedPassword">验证数字签名密码</param>
        /// <param name="ipAddress">IP地址</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状消息</param>
        /// <returns>是否正确</returns>
        public bool SignedPassword(BaseUserInfo userInfo, string signedPassword)
        {
            // 写入调试信息
            #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);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    returnValue = userManager.SignedPassword(signedPassword);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.LogOnService_SignedPassword, 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);
        }
Пример #20
0
        /// <summary>
        /// 单个删除
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>影响行数</returns>
        public int Delete(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    returnValue = userManager.Delete(id);
                    // 用户已经被删除的员工的UserId设置为Null,说白了,是需要整理数据
                    userManager.CheckUserStaff();
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, 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);
        }
Пример #21
0
        /// <summary>
        /// 获取特定用户的新信息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="receiverId">当前交互的用户</param>
        /// <returns>数据表</returns>
        public DataTable ReadFromReceiver(BaseUserInfo userInfo, string receiverId)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            DataTable dataTable = new DataTable(BaseMessageEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo);
                    dataTable           = messageManager.ReadFromReceiver(receiverId);
                    dataTable.TableName = BaseMessageEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.MessageService_ReadFromReceiver, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return(dataTable);
        }
Пример #22
0
        /// <summary>
        /// 获取用户的列权限
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <param name="tableCode">表名</param>
        /// <param name="permissionCode">操作权限</param>
        /// <returns>有权限的列数组</returns>
        public string[] GetColumns(BaseUserInfo userInfo, string tableCode, string permissionCode = "Column.Access")
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            string[] returnValue = null;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    // 获得列表
                    BaseTableColumnsManager manager = new BaseTableColumnsManager(dbHelper, userInfo);
                    returnValue = manager.GetColumns(userInfo.Id, tableCode, permissionCode);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.TableColumnsService_GetDataTableByTable, 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);
        }
Пример #23
0
        private void _Bingfa_Add_Manage_Fun(object obj)
        {
            int         n           = (int)obj;
            IDbHelper   dbHelper    = DbHelperFactory.GetHelper(BaseSystemInfo.CenterDbConnectionString, BaseSystemInfo.CenterDbType);
            UserManager userManager = new UserManager(dbHelper);
            UserEntity  userEntity  = new UserEntity()
            {
                F1           = DateTime.Now.ToString(),
                F2           = new string('a', 50),
                F3           = "333",
                DateTimeType = DateTime.Now,
                NumberType   = n,
                DoubleType   = new Random().Next(1000) * 0.21,
                FloatType    = 1.23456789f,
                DecimalType  = 300.055M,
                NullType     = null,
            };
            string id = userManager.Insert(userEntity);

            Console.WriteLine("returnId:" + id);
        }
Пример #24
0
        public int GetSendVerificationCodeCount(string mobile)
        {
            int    result           = 0;
            string connectionString = string.Empty;

            connectionString = ConfigurationHelper.AppSettings("OpenMasDbConnection", BaseSystemInfo.EncryptDbConnection);
            if (!string.IsNullOrEmpty(connectionString))
            {
                using (IDbHelper dbHelper = DbHelperFactory.GetHelper(CurrentDbType.SqlServer, connectionString))
                {
                    string commandText = @"SELECT COUNT(1) 
                                         FROM SmsSentLog
                                        WHERE UserId = 'VerificationCode' 
                                              AND DestinationAddress = " + dbHelper.GetParameter("Mobile")
                                         + " AND CreateTime > DATEADD(day, -1, GETDATE()) AND CreateTime < GETDATE()";

                    result = int.Parse(dbHelper.ExecuteScalar(commandText, new IDbDataParameter[] { dbHelper.MakeParameter("Mobile", mobile) }).ToString());
                }
            }
            return(result);
        }
Пример #25
0
        private static void ProcessDbHelp(ServiceInfo serviceInfo, ProcessFun processFun, DbType dbType, bool inTransaction)
        {
            // 2016-02-14 吉日嘎拉 增加耗时记录功能
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(GetDbType(dbType), GetDbConnection(dbType)))
            {
                try
                {
                    // dbHelper.Open(GetDbConnection(dbType));
                    if (inTransaction)
                    {
                        // dbHelper.BeginTransaction();
                    }
                    processFun(dbHelper);
                    stopwatch.Stop();
                    serviceInfo.ElapsedTicks = stopwatch.ElapsedTicks;
                    AddLog(serviceInfo);
                    if (inTransaction)
                    {
                        // dbHelper.CommitTransaction();
                    }
                }
                catch (Exception ex)
                {
                    if (inTransaction)
                    {
                        // dbHelper.RollbackTransaction();
                    }
                    BaseExceptionManager.LogException(dbHelper, serviceInfo.UserInfo, ex);
                    throw;
                }
                finally
                {
                    // dbHelper.Close();
                }
            }
        }
Пример #26
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public BaseStaffEntity GetEntity(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            BaseStaffEntity staffEntity = null;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    staffEntity = staffManager.GetEntity(id);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_GetEntity, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return(staffEntity);
        }
Пример #27
0
        /// <summary>
        /// 获取内部通讯录
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="organizeId">组织机构主键</param>
        /// <param name="search">查询内容</param>
        /// <param name="pageSize">分页的条数</param>
        /// <param name="pageIndex">当前页数</param>
        /// <returns>数据表</returns>
        public DataTable GetAddressDataTableByPage(BaseUserInfo userInfo, string organizeId, string searchValue, int pageSize, int pageIndex, out int recordCount)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            DataTable dataTable = new DataTable(BaseStaffEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    dataTable           = staffManager.GetAddressDataTableByPage(out recordCount, pageSize, pageIndex, organizeId, searchValue);
                    dataTable.TableName = BaseStaffEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_GetAddressPageDT, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif
            return(dataTable);
        }
Пример #28
0
        /// <summary>
        /// 获取参数值
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="categoryId">分类主键</param>
        /// <param name="parameterId">参数主键</param>
        /// <param name="parameterCode">参数编号</param>
        /// <returns>参数值</returns>
        public string GetParameter(BaseUserInfo userInfo, string categoryId, string parameterId, string parameterCode)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseParameterManager parameterManager = new BaseParameterManager(dbHelper, userInfo);
                    returnValue = parameterManager.GetParameter(categoryId, parameterId, parameterCode);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.ParameterService_GetParameter, 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);
        }
Пример #29
0
        /// <summary>
        /// 获取约束条件
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="resourceCategory">资源类别</param>
        /// <param name="resourceId">资源主键</param>
        /// <param name="tableName">表名</param>
        /// <returns>约束条件</returns>
        public string GetConstraint(BaseUserInfo userInfo, string resourceCategory, string resourceId, string tableName)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseTableColumnsManager manager = new BaseTableColumnsManager(dbHelper, userInfo);
                    returnValue = manager.GetConstraint(resourceCategory, resourceId, tableName);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.TableColumnsService_SetConstraint, 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);
        }
Пример #30
0
        /// <summary>
        /// 批量发送站内信息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="receiverIds">接受者主键数组</param>
        /// <param name="organizeIds">组织机构主键数组</param>
        /// <param name="roleIds">角色主键数组</param>
        /// <param name="messageEntity">消息内容</param>
        /// <returns>影响行数</returns>
        public int BatchSend(BaseUserInfo userInfo, string[] receiverIds, string[] organizeIds, string[] roleIds, BaseMessageEntity messageEntity)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo);
                    returnValue = messageManager.BatchSend(receiverIds, organizeIds, roleIds, messageEntity, true);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.MessageService_BatchSend, 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);
        }