示例#1
0
        /// <summary>
        /// 获取日志接口
        /// </summary>
        public GetLogContract GetLog(TransType transType, string userId, string userPwd,
                                     string logId)
        {
            string    bizId     = Utils.NewGuid();
            string    methodKey = "LogService.GetLog";
            string    ifCode    = "C013";
            var       data      = new GetLogContract();
            Hashtable htLogExt  = new Hashtable();

            htLogExt["customer_code"] = null;
            htLogExt["customer_id"]   = null;
            htLogExt["unit_code"]     = null;
            htLogExt["unit_id"]       = null;
            htLogExt["user_code"]     = null;
            htLogExt["user_id"]       = userId;
            htLogExt["if_code"]       = ifCode;
            htLogExt["app_code"]      = AppType.Client;
            try
            {
                Hashtable htParams = new Hashtable();
                htParams.Add("trans_type", transType);
                htParams.Add("user_id", userId);
                htParams.Add("user_pwd", userPwd);
                htParams.Add("log_id", logId);
                LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, userId, htLogExt);

                bool      statusFlag = true;
                Hashtable htError    = null;
                CertInfo  certInfo   = null;

                // 检查参数
                Hashtable htResult       = new Hashtable();
                bool      paramCheckFlag = false;
                #region Check Length
                htResult = ErrorService.CheckLength("用户ID", userId, 1, 32, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogContract>(htResult));
                }
                htResult = ErrorService.CheckLength("密码", userPwd, 1, 32, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogContract>(htResult));
                }
                htResult = ErrorService.CheckLength("日志ID", logId, 1, 32, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogContract>(htResult));
                }
                #endregion

                Dex.Services.AuthService authService = new Dex.Services.AuthService();

                // 检查User
                Hashtable htUser = new Hashtable();
                htUser.Add("UserId", userId);
                htUser.Add("CertPwd", userPwd);
                statusFlag = authService.Validate(htUser, ref certInfo);
                if (!statusFlag)
                {
                    htError              = ErrorService.OutputError(ErrorCode.A009, "用户ID与密码不匹配", true);
                    data.status          = Utils.GetStatus(false);
                    data.error_code      = htError["error_code"].ToString();
                    data.error_full_desc = htError["error_desc"].ToString();
                    LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                    return(data);
                }

                // 获取数据
                Services.LogDBService logDBService = new Services.LogDBService();
                LogInfo log = logDBService.GetLogById(logId);
                if (log != null)
                {
                    LogContract logContract = new LogContract();
                    logContract.log_id         = log.LogId;
                    logContract.biz_id         = log.BizId;
                    logContract.biz_name       = log.BizName;
                    logContract.log_type_id    = log.LogTypeId;
                    logContract.log_type_code  = log.LogTypeCode;
                    logContract.log_code       = log.LogCode;
                    logContract.log_body       = log.LogBody;
                    logContract.create_time    = log.CreateTime;
                    logContract.create_user_id = log.CreateUserId;
                    logContract.modify_time    = log.ModifyTime;
                    logContract.modify_user_id = log.ModifyUserId;
                    logContract.customer_code  = log.CustomerCode;
                    logContract.customer_id    = log.CustomerId;
                    logContract.unit_code      = log.UnitCode;
                    logContract.unit_id        = log.UnitId;
                    logContract.user_code      = log.UserCode;
                    logContract.user_id        = log.UserId;
                    logContract.if_code        = log.IfCode;
                    logContract.app_code       = log.AppCode;
                    data.Log = logContract;
                }

                data.status = Utils.GetStatus(statusFlag);
                LogService.WriteTrace(bizId, methodKey, TraceLogType.Return.ToString(), data.ToString(), userId, htLogExt);
            }
            catch (Exception ex)
            {
                data.status          = Utils.GetStatus(false);
                data.error_code      = ErrorCode.A000.ToString();
                data.error_full_desc = ex.ToString();
                LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
            }
            return(data);
        }
示例#2
0
        public static T Export <T>(Hashtable htError) where T : BaseContract
        {
            BaseContract contract = null;

            if (typeof(T) == typeof(BaseContract))
            {
                contract = new BaseContract();
            }
            if (typeof(T) == typeof(ValidateContract))
            {
                contract = new ValidateContract();
            }
            if (typeof(T) == typeof(GetUserUnitRelationsContract))
            {
                contract = new GetUserUnitRelationsContract();
            }
            if (typeof(T) == typeof(GetUsersProfileContract))
            {
                contract = new GetUsersProfileContract();
            }
            if (typeof(T) == typeof(GetPosCodeContract))
            {
                contract = new GetPosCodeContract();
            }
            if (typeof(T) == typeof(GetLogsContract))
            {
                contract = new GetLogsContract();
            }
            if (typeof(T) == typeof(GetLogContract))
            {
                contract = new GetLogContract();
            }
            if (typeof(T) == typeof(GetPackagesContract))
            {
                contract = new GetPackagesContract();
            }
            if (typeof(T) == typeof(GetPackagesCountContract))
            {
                contract = new GetPackagesCountContract();
            }
            if (typeof(T) == typeof(GetPackageFilesContract))
            {
                contract = new GetPackageFilesContract();
            }
            if (typeof(T) == typeof(GetPackageFilesCountContract))
            {
                contract = new GetPackageFilesCountContract();
            }
            if (typeof(T) == typeof(UploadInoutOrdersContract))
            {
                contract = new UploadInoutOrdersContract();
            }
            if (typeof(T) == typeof(GetCountContract))
            {
                contract = new GetCountContract();
            }
            if (typeof(T) == typeof(GetStockBalancesContract))
            {
                contract = new GetStockBalancesContract();
            }
            if (typeof(T) == typeof(UploadContract))
            {
                contract = new UploadContract();
            }
            if (typeof(T) == typeof(GetVipsContract))
            {
                contract = new GetVipsContract();
            }
            if (typeof(T) == typeof(GetVipContract))
            {
                contract = new GetVipContract();
            }
            if (typeof(T) == typeof(ExistVipNoContract))
            {
                contract = new ExistVipNoContract();
            }
            if (typeof(T) == typeof(DownloadInoutOrdersContract))
            {
                contract = new DownloadInoutOrdersContract();
            }
            if (typeof(T) == typeof(DownloadCcOrdersContract))
            {
                contract = new DownloadCcOrdersContract();
            }
            if (typeof(T) == typeof(GetAnnsContract))
            {
                contract = new GetAnnsContract();
            }
            if (typeof(T) == typeof(GetPriceOrdersContract))
            {
                contract = new GetPriceOrdersContract();
            }
            if (typeof(T) == typeof(CheckVersionContract))
            {
                contract = new CheckVersionContract();
            }
            if (typeof(T) == typeof(GetUnitXmlConfigInfoContract))
            {
                contract = new GetUnitXmlConfigInfoContract();
            }
            if (typeof(T) == typeof(GetItemInfoContract))
            {
                contract = new GetItemInfoContract();
            }
            if (typeof(T) == typeof(ApplyCustomerAndUnitContract))
            {
                contract = new ApplyCustomerAndUnitContract();
            }

            contract.status          = htError["status"].ToString();
            contract.error_code      = htError["error_code"].ToString();
            contract.error_full_desc = htError["error_desc"].ToString();
            return((T)contract);
        }