예제 #1
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);
        }
예제 #2
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);
        }
예제 #3
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);
        }