Esempio n. 1
0
        /// <summary>
        /// 获取树视图(根据令牌)
        /// </summary>
        /// <param name="access_token">登录token</param>
        /// <returns></returns>
        public List <TreeViewDTO> AccessibleTreeView(string access_token)
        {
            IRAPLog     log  = new IRAPLog();
            LoginEntity logE = log.GetLogIDByToken(access_token);

            if (logE == null)
            {
                int    errCode = 99;
                string errText = "无法访问树数据,令牌无效!";
                throw new Exception($"{errCode}-{errText}");
            }
            return(AccessibleTreeView(logE.AgencyLeaf, logE.RoleLeaf));
        }
Esempio n. 2
0
        /// <summary>
        /// 开启业务操作的基础
        /// </summary>
        /// <param name="dbName"></param>
        /// <param name="access_token"></param>
        /// <param name="opID"></param>
        public IRAPOperBase(string dbName, string access_token, int opID)
        {
            _opID             = opID;
            _db               = DBContextFactory.Instance.CreateContext(dbName + "Context");
            this.access_token = access_token;
            var logDB = new IRAPLog();

            log = logDB.GetLogIDByToken(access_token);
            if (log != null)
            {
                _communityID = (int)log.PartitioningKey / 10000;
            }
            if (_communityID == 0)
            {
                throw new Exception($"令牌access_token={access_token}无效!");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="db">数据库上下文</param>
        /// <param name="access_token">登录令牌</param>
        /// <param name="opID">业务操作</param>
        public IRAPOperBase(IDbContext db, string access_token, int opID)
        {
            _db               = db;
            _opID             = opID;
            this.access_token = access_token;
            var logDB = new IRAPLog();

            log = logDB.GetLogIDByToken(access_token);
            if (log != null)
            {
                _communityID = (int)log.PartitioningKey / 10000;
            }
            if (_communityID == 0)
            {
                throw new Exception($"令牌access_token={access_token}无效!");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 获取可用系统(带权限)
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="progLangID"></param>
        /// <returns></returns>
        public List <SystemDTO> GetAvailableSystems(string access_token, short progLangID)
        {
            IRAPLog          log         = new IRAPLog();
            LoginEntity      logEntity   = log.GetLogIDByToken(access_token);
            int              communityID = (int)(logEntity.PartitioningKey / 10000L);
            var              list        = GetSystemList(progLangID);
            IRAPTreeSet      treeSet     = new IRAPTreeSet(communityID, 3);
            List <SystemDTO> resList     = new List <SystemDTO>();

            foreach (var r in list)
            {
                List <TreeViewDTO> accessList = treeSet.AccessibleTreeView(r.SystemID, logEntity.AgencyLeaf, logEntity.RoleLeaf);
                if (accessList.Count < 2)
                {
                    continue;
                }
                resList.Add(r);
            }
            return(resList);
        }
Esempio n. 5
0
        /// <summary>
        /// 根据社区标识和系统登录标识获取登录用户信息
        /// </summary>
        /// <param name="communityID">社区标识</param>
        /// <param name="sysLogID">系统登录标识</param>
        /// <param name="loginInfo">输出参数,登录用户信息</param>
        /// <returns>IRAP系统通用错误对象,如果其中的ErrCode:0-执行成功;非0执行失败</returns>
        private IRAPError GetUserInfoWithSysLogID(
            int communityID,
            long sysLogID,
            out LoginEntity loginInfo)
        {
            #region 根据系统登录标识获取登录信息
            IRAPError rlt = new IRAPError();
            loginInfo = null;
            try
            {
                IRAPLog loginSet = new IRAPLog();
                loginInfo = loginSet.GetLogin(communityID, sysLogID);
                if (loginInfo == null)
                {
                    loginInfo = new LoginEntity()
                    {
                        UserCode   = "Unknown",
                        LanguageID = 30,
                    };
                }
            }
            catch (Exception error)
            {
                if (error.InnerException.InnerException != null)
                {
                    rlt.ErrText =
                        $"获取登录信息发生异常:" +
                        $"{error.InnerException.InnerException.Message}";
                }
                else
                {
                    rlt.ErrText = $"获取登录信息发生异常:{error.Message}";
                }
                rlt.ErrCode = 9999;
            }
            #endregion

            return(rlt);
        }
Esempio n. 6
0
 /// <summary>
 /// 申请交易号
 /// </summary>
 /// <param name="cnt">申请数量</param>
 /// <param name="remark">交易备注</param>
 /// <param name="opNodes">操作类型清单,多个用逗号隔开</param>
 /// <param name="voucherNo">票据号</param>
 /// <returns></returns>
 public long GetTransactNo(int cnt = 1, string remark = "", string opNodes = "", string voucherNo = "")
 {
     try
     {
         if (opNodes == "")
         {
             opNodes = (-_opID).ToString();
         }
         LoginEntity log = new IRAPLog().GetLogIDByToken(access_token);
         if (log == null)
         {
             throw new Exception("申请交易号时出错,令牌无效!");
         }
         long           transactNo = IRAPSequence.GetTransactNo();
         TransactEntity e          = new TransactEntity()
         {
             AgencyLeaf1     = log.AgencyLeaf,
             IPAddress       = log.IPAddress,
             Operator        = log.UserCode,
             OperTime        = DateTime.Now,
             OpNodes         = _opID.ToString(),
             PartitioningKey = TransPK,
             StationID       = log.StationID,
             Status          = 1,
             Remark          = remark,
             TransactNo      = transactNo,
             VoucherNo       = voucherNo
         };
         _db.Set <TransactEntity>().Add(e);
         _db.SaveChanges();
         return(transactNo);
     }
     catch (Exception err)
     {
         throw err;
     }
 }
Esempio n. 7
0
        /// <summary>
        /// 更新参数值
        /// </summary>
        /// <param name="communityID">社区标识</param>
        /// <param name="paramID">参数标识</param>
        /// <param name="paramValue">参数值(整型)</param>
        /// <param name="sysLogID">系统登录标识</param>
        /// <returns>IRAP系统通用错误对象,如果其中的ErrCode:0-执行成功;非0执行失败</returns>
        public IRAPError Modify(
            int communityID,
            byte paramID,
            int paramValue,
            long sysLogID)
        {
            IRAPError rlt = new IRAPError();

            #region 根据系统登录标识获取登录信息
            LoginEntity loginInfo = null;
            try
            {
                IRAPLog loginSet = new IRAPLog();
                loginInfo = loginSet.GetLogin(communityID, sysLogID);
                if (loginInfo == null)
                {
                    loginInfo = new LoginEntity()
                    {
                        UserCode   = "Unknown",
                        LanguageID = 30,
                    };
                }
            }
            catch (Exception error)
            {
                if (error.InnerException.InnerException != null)
                {
                    rlt.ErrText =
                        $"获取登录信息发生异常:" +
                        $"{error.InnerException.InnerException.Message}";
                }
                else
                {
                    rlt.ErrText = $"获取登录信息发生异常:{error.Message}";
                }
                rlt.ErrCode = 9999;

                return(rlt);
            }
            #endregion

            List <IRAPParameterDTO> iParams = GetByParamID(communityID, new int[] { paramID });
            if (iParams.Count <= 0)
            {
                rlt.ErrCode = 9999;
                rlt.ErrText = $"[{communityID}]社区中未找到ParameterID=[{paramID}]的参数";
                return(rlt);
            }

            try
            {
                irapParams.Update(
                    new IRAPParameterEntity()
                {
                    PartitioningKey   = iParams[0].PartitioningKey,
                    ParameterID       = iParams[0].ParameterID,
                    ParameterNameID   = iParams[0].ParameterNameID,
                    ParameterValue    = paramValue,
                    ParameterValueStr = iParams[0].ParameterValueStr,
                    UpdatedBy         = loginInfo.UserCode,
                    TimeUpdated       = DateTime.Now,
                });
                irapParams.SaveChanges();
                rlt.ErrCode = 0;
                rlt.ErrText = "更新参数值(整型)成功";
            }
            catch (Exception error)
            {
                rlt.ErrCode = 9999;
                if (error.InnerException.InnerException != null)
                {
                    rlt.ErrText =
                        $"更新参数值发生异常:" +
                        $"{error.InnerException.InnerException.Message}";
                }
                else
                {
                    rlt.ErrText = $"更新参数值发生异常:{error.Message}";
                }
            }

            return(rlt);
        }
Esempio n. 8
0
        /// <summary>
        /// 新增参数
        /// </summary>
        /// <remarks>本方法需要在序列服务器中配置NextParameterID序列</remarks>
        /// <param name="communityID">社区标识</param>
        /// <param name="paramName">参数名称</param>
        /// <param name="paramValue">参数值(整型)</param>
        /// <param name="paramStrValue">参数值(字符串)</param>
        /// <param name="sysLogID">系统登录标识</param>
        /// <param name="paramID">输出参数,新增参数的参数标识</param>
        /// <returns>IRAP系统通用错误对象,如果其中的ErrCode:0-执行成功;非0执行失败</returns>
        public IRAPError Add(
            int communityID,
            string paramName,
            int paramValue,
            string paramStrValue,
            long sysLogID,
            out int paramID)
        {
            IRAPError rlt = new IRAPError();

            paramID = 0;

            LoginEntity loginInfo = null;

            try
            {
                IRAPLog loginSet = new IRAPLog();
                loginInfo = loginSet.GetLogin(communityID, sysLogID);
                if (loginInfo == null)
                {
                    loginInfo = new LoginEntity()
                    {
                        UserCode   = "Unknown",
                        LanguageID = 30,
                    };
                }
            }
            catch (Exception error)
            {
                if (error.InnerException.InnerException != null)
                {
                    rlt.ErrText =
                        $"获取登录信息发生异常:" +
                        $"{error.InnerException.InnerException.Message}";
                }
                else
                {
                    rlt.ErrText = $"获取登录信息发生异常:{error.Message}";
                }
                rlt.ErrCode = 9999;

                return(rlt);
            }

            IIRAPNamespaceSet namespaceSet =
                IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys);

            rlt =
                namespaceSet.Add(
                    communityID,
                    paramName,
                    loginInfo.LanguageID,
                    out int nameID);
            if (rlt.ErrCode != 0)
            {
                return(rlt);
            }

            rlt = RequestParameterID(out paramID);
            if (rlt.ErrCode != 0)
            {
                return(rlt);
            }

            IRAPParameterEntity entity = new IRAPParameterEntity()
            {
                ParameterID       = (byte)paramID,
                ParameterNameID   = nameID,
                PartitioningKey   = communityID * 10000,
                ParameterValue    = paramValue,
                ParameterValueStr = paramStrValue,
                UpdatedBy         = loginInfo.UserCode,
                TimeUpdated       = DateTime.Now,
            };

            try
            {
                irapParams.Insert(entity);
                irapParams.SaveChanges();
                rlt.ErrCode = 0;
                rlt.ErrText = "参数新增成功";
            }
            catch (Exception error)
            {
                rlt.ErrCode = 9999;
                if (error.InnerException.InnerException != null)
                {
                    rlt.ErrText =
                        $"新增参数发生异常:" +
                        $"{error.InnerException.InnerException.Message}";
                }
                else
                {
                    rlt.ErrText = $"新增参数发生异常:{error.Message}";
                }
            }

            return(rlt);
        }