Ejemplo n.º 1
0
        public cPos.Model.MonitorLogInfo ToMonitorLogModel(MonitorLogContract model)
        {
            var obj = new cPos.Model.MonitorLogInfo();

            obj.monitor_log_id = model.monitor_log_id;
            obj.customer_id    = model.customer_id;
            obj.unit_id        = model.unit_id;
            obj.pos_id         = model.pos_id;
            obj.upload_time    = model.upload_time;
            obj.remark         = model.remark;
            obj.create_time    = model.create_time;
            obj.create_user_id = model.create_user_id;
            return(obj);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 检查MonitorLog
        /// </summary>
        public Hashtable CheckMonitorLog(MonitorLogContract order)
        {
            Hashtable htError = new Hashtable();

            if (order == null)
            {
                htError = ErrorService.OutputError(ErrorCode.A016, "信息不能为空", true);
                return(htError);
            }
            if (order.user_id == null || order.user_id.Trim().Length == 0)
            {
                htError = ErrorService.OutputError(ErrorCode.A016, "用户标识不能为空", true);
                return(htError);
            }
            htError["status"] = Utils.GetStatus(true);
            return(htError);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存MonitorLog
        /// </summary>
        public void SaveMonitorLog(MonitorLogContract order,
                                   string customerId, string unitId, string userId)
        {
            if (order.monitor_log_id == null || order.monitor_log_id.Trim().Length == 0)
            {
                order.monitor_log_id = Utils.NewGuid();
            }

            if (order.upload_time == null || order.upload_time.Trim().Length == 0)
            {
                order.upload_time = Utils.GetNow();
            }

            order.customer_id    = customerId;
            order.create_user_id = userId;
            order.create_time    = Utils.GetNow();

            var orderInfo = ToMonitorLogModel(order);

            // Save
            var logService = new ExchangeBsService.MonitorLogAuthService();

            logService.SetMonitorLogInfo(customerId, unitId, userId, orderInfo);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 上传 MonitorLog 信息接口
        /// </summary>
        public UploadContract UploadMonitorLog(TransType transType,
                                               MonitorLogContract order, string userId, string token, string unitId)
        {
            string    bizId     = Utils.NewGuid();
            string    methodKey = "ComService.UploadMonitorLog";
            string    ifCode    = "C001";
            var       data      = new UploadContract();
            Hashtable htLogExt  = new Hashtable();

            htLogExt["customer_code"] = null;
            htLogExt["customer_id"]   = null;
            htLogExt["unit_code"]     = null;
            htLogExt["unit_id"]       = unitId;
            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("order", order);
                htParams.Add("user_id", userId);
                htParams.Add("token", token);
                htParams.Add("unit_id", unitId);
                LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, userId, htLogExt);

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

                #region 检查参数
                Hashtable htResult       = new Hashtable();
                bool      paramCheckFlag = false;
                htResult = ErrorService.CheckLength("用户ID", userId, 1, 32, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <UploadContract>(htResult));
                }
                //htResult = ErrorService.CheckLength("令牌", token, 1, 32, true, false, ref paramCheckFlag);
                //if (!paramCheckFlag) return ErrorConvert.Export<UploadContract>(htResult);
                //htResult = ErrorService.CheckLength("门店ID", unitId, 1, 32, true, false, ref paramCheckFlag);
                //if (!paramCheckFlag) return ErrorConvert.Export<UploadContract>(htResult);
                #endregion

                #region 检查权限
                Dex.Services.AuthService authService = new Dex.Services.AuthService();

                // 检查User和Customer
                certInfo = authService.GetCertByUserId(userId);
                if (certInfo == null)
                {
                    htError              = ErrorService.OutputError(ErrorCode.A006, "用户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);
                }

                statusFlag = true;
                //// 检查Token是否不匹配或过期
                //statusFlag = authService.CheckCertToken(token, certInfo.CertId, userId);
                //if (!statusFlag)
                //{
                //    htError = ErrorService.OutputError(ErrorCode.A005, "令牌不匹配或过期", 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;
                //}

                // 查询凭证
                certInfo = authService.GetCertByUserId(userId);
                if (certInfo == null || certInfo.CustomerId == null || certInfo.CustomerId.Length == 0)
                {
                    htError              = ErrorService.OutputError(ErrorCode.A007, "获取后台数据(客户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);
                }

                string customerId = certInfo.CustomerId;

                htLogExt["customer_code"] = certInfo.CustomerCode;
                htLogExt["customer_id"]   = certInfo.CustomerId;
                htLogExt["user_code"]     = certInfo.UserCode;
                #endregion

                #region 检查单据参数
                Dex.ServicesBs.ComService orderService = new Dex.ServicesBs.ComService();
                if (order.user_id == null || order.user_id.Trim().Length == 0)
                {
                    order.user_id = userId;
                }
                htError = orderService.CheckMonitorLog(order);
                if (!Convert.ToBoolean(htError["status"]))
                {
                    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);
                }
                #endregion

                // 保存
                ConfigService cfgService         = new ConfigService();
                bool          enableConnectPosBS = cfgService.GetEnableConnectPosBSCfg();
                if (enableConnectPosBS)
                {
                    try
                    {
                        orderService.SaveMonitorLog(order, customerId, unitId, userId);
                    }
                    catch (Exception ex)
                    {
                        data.status          = Utils.GetStatus(false);
                        data.error_code      = ErrorCode.A018.ToString();
                        data.error_full_desc = ex.ToString();
                        LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                        return(data);
                    }
                }
                else
                {
                    htError              = ErrorService.OutputError(ErrorCode.A012, "连接业务平台数据通道已关闭", 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);
                }

                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);
        }
Ejemplo n.º 5
0
 public UploadContract UploadMonitorLogJson(MonitorLogContract order,
                                            string userId, string token, string unitId)
 {
     return(UploadMonitorLog(TransType.JSON, order, userId, token, unitId));
 }