Exemple #1
0
        public BaseContract Run(PackageGenTypeMethod packageGenType,
                                string batId, string customerId, string unitId, string userId)
        {
            int       pageSize  = 500; // 每页数量
            AppType   appType   = AppType.AP;
            string    bizId     = Utils.NewGuid();
            string    methodKey = "Task.PackageMobile";
            string    ifCode    = TaskCode.T011.ToString();
            var       data      = new BaseContract();
            Hashtable htLogExt  = new Hashtable();

            htLogExt["customer_code"] = null;
            htLogExt["customer_id"]   = customerId;
            htLogExt["unit_code"]     = null;
            htLogExt["unit_id"]       = unitId;
            htLogExt["user_code"]     = null;
            htLogExt["user_id"]       = userId;
            htLogExt["if_code"]       = ifCode;
            htLogExt["app_code"]      = appType.ToString();
            try
            {
                Hashtable htParams = new Hashtable();
                htParams.Add("package_gen_type", packageGenType);
                htParams.Add("bat_id", batId);
                htParams.Add("customer_id", customerId);
                htParams.Add("unit_id", unitId);
                htParams.Add("user_id", userId);
                LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, userId, htLogExt);

                bool statusFlag = true;

                // 检查参数
                Hashtable htResult       = new Hashtable();
                bool      paramCheckFlag = false;
                #region Check Length
                htResult = ErrorService.CheckLength("用户ID", userId, 1, 50, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    throw new Exception(string.Format("批次{0}:用户ID不能为空", batId));
                }
                #endregion

                htLogExt["customer_id"] = customerId;

                var dataService = new cPos.Admin.Service.SkuService();

                // 获取总数量
                int count = dataService.GetSkuNotPackagedCount();
                if (count <= 0)
                {
                    data.status = Utils.GetStatus(true);
                    return(data);
                }

                // 创建数据包
                string         pkgTypeCode    = PackageTypeMethod.MOBILE.ToString();
                string         pkgGenTypeCode = packageGenType.ToString();
                PackageService pkgService     = new PackageService();
                Hashtable      htPkg          = pkgService.CreatePackage(appType, batId, pkgTypeCode,
                                                                         customerId, unitId, userId, pkgGenTypeCode, null, null, "MOBILE");
                if (!Convert.ToBoolean(htPkg["status"]))
                {
                    data.status          = Utils.GetStatus(false);
                    data.error_code      = htPkg["error_code"].ToString();
                    data.error_full_desc = htPkg["error_desc"].ToString();
                    LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                    Console.WriteLine(data.error_full_desc);
                    return(data);
                }
                string pkgId = htPkg["package_id"].ToString();

                // 循环生成数据包文件
                int num = 0;
                while (num <= count)
                {
                    IList <cPos.Model.SkuInfo> items = dataService.GetSkuListPackaged(pageSize, num);
                    if (items.Count <= 0)
                    {
                        break;
                    }
                    num += pageSize;

                    Hashtable htPkgf = pkgService.CreateMobileSkusPackageFile(
                        appType, batId, pkgId, userId, null, items);
                    if (!Convert.ToBoolean(htPkgf["status"]))
                    {
                        data.status          = Utils.GetStatus(false);
                        data.error_code      = htPkgf["error_code"].ToString();
                        data.error_full_desc = htPkgf["error_desc"].ToString();
                        LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                        Console.WriteLine(data.error_full_desc);
                        return(data);
                    }
                    // 记录数据打包批次号
                    dataService.SetSkuBatInfo(batId, items, userId);
                }

                // 发布数据包
                Hashtable htPkgPublish = pkgService.PublishPackage(appType, batId, pkgId, userId);
                if (!Convert.ToBoolean(htPkgPublish["status"]))
                {
                    data.status          = Utils.GetStatus(false);
                    data.error_code      = htPkgPublish["error_code"].ToString();
                    data.error_full_desc = htPkgPublish["error_desc"].ToString();
                    LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                    Console.WriteLine(data.error_full_desc);
                    return(data);
                }

                // 更新数据打包标识
                dataService.SetSkuIfFlagInfo(batId, userId);

                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);
                Console.WriteLine(data.error_full_desc);
            }
            return(data);
        }
Exemple #2
0
        public BaseContract Run(PackageGenTypeMethod packageGenType,
                                string batId, string customerId, string unitId, string userId)
        {
            int       pageSize  = 500;                        // 每页数量
            AppType   appType   = AppType.BS;                 //平台类型
            string    bizId     = Utils.NewGuid();
            string    methodKey = "Task.PackageObjectImages"; //定义任务主键
            string    ifCode    = TaskCode.T013.ToString();   //任务编号
            var       data      = new BaseContract();
            Hashtable htLogExt  = new Hashtable();

            htLogExt["customer_code"] = null;
            htLogExt["customer_id"]   = customerId;
            htLogExt["unit_code"]     = null;
            htLogExt["unit_id"]       = unitId;
            htLogExt["user_code"]     = null;
            htLogExt["user_id"]       = userId;
            htLogExt["if_code"]       = ifCode;
            htLogExt["app_code"]      = appType.ToString();
            try
            {
                Hashtable htParams = new Hashtable();
                htParams.Add("package_gen_type", packageGenType);
                htParams.Add("bat_id", batId);
                htParams.Add("customer_id", customerId);
                htParams.Add("unit_id", unitId);
                htParams.Add("user_id", userId);
                LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, userId, htLogExt);

                bool statusFlag = true;

                // 检查参数
                Hashtable htResult       = new Hashtable();
                bool      paramCheckFlag = false;
                #region Check Length
                htResult = ErrorService.CheckLength("客户ID", customerId, 1, 50, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    throw new Exception(string.Format("批次{0}:客户ID不能为空", batId));
                }
                htResult = ErrorService.CheckLength("门店ID", unitId, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    throw new Exception(string.Format("批次{0}:门店ID不能为空", batId));
                }
                #endregion

                htLogExt["customer_id"] = customerId;

                var dataService = new ExchangeBsService.ObjectImagesBsService();                     //调用中间服务
                // 获取总数量
                int count = dataService.GetObjectImagesNotPackagedCount(customerId, userId, unitId); //获取未打包的商品数量
                if (count <= 0)
                {
                    data.status = Utils.GetStatus(true);
                    return(data);
                }

                // 创建数据包
                string         pkgTypeCode    = PackageTypeMethod.ObjectImages.ToString();//打包类型
                string         pkgGenTypeCode = packageGenType.ToString();
                PackageService pkgService     = new PackageService();
                Hashtable      htPkg          = pkgService.CreatePackage(appType, batId, pkgTypeCode,
                                                                         customerId, unitId, userId, pkgGenTypeCode, null);//创建数据包**使用操作数据库之外的打包程序
                if (!Convert.ToBoolean(htPkg["status"]))
                {
                    data.status          = Utils.GetStatus(false);
                    data.error_code      = htPkg["error_code"].ToString();
                    data.error_full_desc = htPkg["error_desc"].ToString();
                    LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                    Console.WriteLine(data.error_full_desc);
                    return(data);
                }
                string pkgId = htPkg["package_id"].ToString();  //文件夹的名字

                // 循环生成数据包文件
                int num = 0;
                while (num <= count)
                {
                    //使用实体类
                    IList <cPos.Model.ObjectImagesInfo> items = dataService.GetItemListPackaged(
                        customerId, userId, unitId, num, pageSize);  //获取未打包的图片集合
                    if (items.Count <= 0)
                    {
                        break;
                    }
                    num += pageSize;

                    //foreach (var item in items)
                    //{
                    //    item.ItemPropList = dataService.GetItemPropInfoListPackaged(
                    //        customerId, userId, unitId, item.Item_Id);
                    //}

                    //创建文件包
                    Hashtable htPkgf = pkgService.CreateObjectImagessPackageFile(
                        appType, batId, pkgId, userId, null, items);
                    if (!Convert.ToBoolean(htPkgf["status"]))
                    {
                        data.status          = Utils.GetStatus(false);
                        data.error_code      = htPkgf["error_code"].ToString();
                        data.error_full_desc = htPkgf["error_desc"].ToString();
                        LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                        Console.WriteLine(data.error_full_desc);
                        return(data);
                    }
                    // 记录数据打包批次号
                    dataService.SetObjectImagesBatInfo(customerId, userId, unitId, batId, items);
                }

                // 发布数据包
                Hashtable htPkgPublish = pkgService.PublishPackage(appType, batId, pkgId, userId);
                if (!Convert.ToBoolean(htPkgPublish["status"]))
                {
                    data.status          = Utils.GetStatus(false);
                    data.error_code      = htPkgPublish["error_code"].ToString();
                    data.error_full_desc = htPkgPublish["error_desc"].ToString();
                    LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                    Console.WriteLine(data.error_full_desc);
                    return(data);
                }

                // 更新数据打包标识
                dataService.SetObjectImagesIfFlagInfo(customerId, userId, unitId, batId);

                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);
                Console.WriteLine(data.error_full_desc);
            }
            return(data);
        }
Exemple #3
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);
        }
Exemple #4
0
        public BaseContract Run(PackageGenTypeMethod packageGenType,
                                string batId, string customerId, string unitId, string userId)
        {
            int       pageSize  = 1000; // 每页数量
            AppType   appType   = AppType.AP;
            string    bizId     = Utils.NewGuid();
            string    methodKey = "Task.PackageMobileUnit";
            string    ifCode    = TaskCode.T012.ToString();
            var       data      = new BaseContract();
            Hashtable htLogExt  = new Hashtable();

            htLogExt["customer_code"] = null;
            htLogExt["customer_id"]   = customerId;
            htLogExt["unit_code"]     = null;
            htLogExt["unit_id"]       = unitId;
            htLogExt["user_code"]     = null;
            htLogExt["user_id"]       = userId;
            htLogExt["if_code"]       = ifCode;
            htLogExt["app_code"]      = appType.ToString();
            try
            {
                Hashtable htParams = new Hashtable();
                htParams.Add("package_gen_type", packageGenType);
                htParams.Add("bat_id", batId);
                htParams.Add("customer_id", customerId);
                htParams.Add("unit_id", unitId);
                htParams.Add("user_id", userId);
                LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, userId, htLogExt);

                bool statusFlag = true;

                // 检查参数
                Hashtable htResult       = new Hashtable();
                bool      paramCheckFlag = false;
                #region Check Length
                htResult = ErrorService.CheckLength("用户ID", userId, 1, 50, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    throw new Exception(string.Format("批次{0}:用户ID不能为空", batId));
                }
                #endregion

                htLogExt["customer_id"] = customerId;

                var dataService       = new ExchangeBsService.UnitBsService();
                var apCustomerService = new cPos.Admin.Service.Implements.CustomerService();

                // 获取总数量
                int customersCount = apCustomerService.GetMobileCustomerNotPackagedCount(customerId, userId, unitId);
                int unitsCount     = apCustomerService.GetMobileCustomerShopNotPackagedCount(customerId, userId, unitId);
                if (customersCount <= 0 && unitsCount <= 0)
                {
                    data.status = Utils.GetStatus(true);
                    return(data);
                }

                // 创建数据包
                string         pkgTypeCode    = PackageTypeMethod.MOBILE.ToString();
                string         pkgGenTypeCode = packageGenType.ToString();
                PackageService pkgService     = new PackageService();
                Hashtable      htPkg          = pkgService.CreatePackage(appType, batId, pkgTypeCode,
                                                                         customerId, unitId, userId, pkgGenTypeCode, null, null, AppType.MOBILE.ToString());
                if (!Convert.ToBoolean(htPkg["status"]))
                {
                    data.status          = Utils.GetStatus(false);
                    data.error_code      = htPkg["error_code"].ToString();
                    data.error_full_desc = htPkg["error_desc"].ToString();
                    LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                    Console.WriteLine(data.error_full_desc);
                    return(data);
                }
                string pkgId = htPkg["package_id"].ToString();

                // 循环生成数据包文件
                int num = 0;
                IList <cPos.Admin.Model.Customer.CustomerInfo> customers = apCustomerService.GetMobileCustomerListNotPackaged(
                    customerId, userId, unitId, num, pageSize);
                IList <cPos.Admin.Model.Customer.CustomerShopInfo> units = apCustomerService.GetMobileCustomerShopListNotPackaged(
                    customerId, userId, unitId, num, pageSize);


                Hashtable htPkgf = pkgService.CreateMoblieCustomerAndUnitsPackageFile(
                    appType, batId, pkgId, userId, null, customers, units);
                if (!Convert.ToBoolean(htPkgf["status"]))
                {
                    data.status          = Utils.GetStatus(false);
                    data.error_code      = htPkgf["error_code"].ToString();
                    data.error_full_desc = htPkgf["error_desc"].ToString();
                    LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                    Console.WriteLine(data.error_full_desc);
                    return(data);
                }
                // 记录数据打包批次号
                apCustomerService.SetMobileCustomerBatInfo(customerId, userId, unitId, batId, customers);
                apCustomerService.SetMobileCustomerShopBatInfo(customerId, userId, unitId, batId, units);


                // 发布数据包
                Hashtable htPkgPublish = pkgService.PublishPackage(appType, batId, pkgId, userId);
                if (!Convert.ToBoolean(htPkgPublish["status"]))
                {
                    data.status          = Utils.GetStatus(false);
                    data.error_code      = htPkgPublish["error_code"].ToString();
                    data.error_full_desc = htPkgPublish["error_desc"].ToString();
                    LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                    Console.WriteLine(data.error_full_desc);
                    return(data);
                }

                // 更新数据打包标识
                apCustomerService.UpdateMobileCustomerNotPackagedIfFlag(customerId, userId, unitId, batId);
                apCustomerService.UpdateMobileCustomerShopNotPackagedIfFlag(customerId, userId, unitId, batId);

                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);
                Console.WriteLine(data.error_full_desc);
            }
            return(data);
        }
Exemple #5
0
        public BaseContract Run(PackageGenTypeMethod packageGenType,
                                string batId, string customerId, string unitId, string userId)
        {
            //int pageSize = 500; // 每页数量
            AppType   appType   = AppType.BS;
            string    bizId     = Utils.NewGuid();
            string    methodKey = "Task.PackageSkuProps";
            string    ifCode    = TaskCode.T006.ToString();
            var       data      = new BaseContract();
            Hashtable htLogExt  = new Hashtable();

            htLogExt["customer_code"] = null;
            htLogExt["customer_id"]   = customerId;
            htLogExt["unit_code"]     = null;
            htLogExt["unit_id"]       = unitId;
            htLogExt["user_code"]     = null;
            htLogExt["user_id"]       = userId;
            htLogExt["if_code"]       = ifCode;
            htLogExt["app_code"]      = appType.ToString();
            try
            {
                Hashtable htParams = new Hashtable();
                htParams.Add("package_gen_type", packageGenType);
                htParams.Add("bat_id", batId);
                htParams.Add("customer_id", customerId);
                htParams.Add("unit_id", unitId);
                htParams.Add("user_id", userId);
                LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, userId, htLogExt);

                bool statusFlag = true;

                // 检查参数
                Hashtable htResult       = new Hashtable();
                bool      paramCheckFlag = false;
                #region Check Length
                htResult = ErrorService.CheckLength("客户ID", customerId, 1, 50, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    throw new Exception(string.Format("批次{0}:客户ID不能为空", batId));
                }
                htResult = ErrorService.CheckLength("门店ID", unitId, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    throw new Exception(string.Format("批次{0}:门店ID不能为空", batId));
                }
                #endregion

                htLogExt["customer_id"] = customerId;

                var dataService = new ExchangeBsService.SkuBsService();

                string         pkgTypeCode    = PackageTypeMethod.SKUPROPS.ToString();
                string         pkgGenTypeCode = packageGenType.ToString();
                PackageService pkgService     = new PackageService();

                // 判断是否已打包
                var isPackaged = pkgService.CheckIsPackaged(customerId, pkgTypeCode);
                if (isPackaged > 0)
                {
                    data.status = Utils.GetStatus(true);
                    return(data);
                }

                // 获取数据
                var items = dataService.GetSkuPropListPackage(customerId, userId, unitId);
                if (items == null || items.Count <= 0)
                {
                    data.status = Utils.GetStatus(true);
                    return(data);
                }

                // 创建数据包
                Hashtable htPkg = pkgService.CreatePackage(appType, batId, pkgTypeCode,
                                                           customerId, null, userId, pkgGenTypeCode, null);
                if (!Convert.ToBoolean(htPkg["status"]))
                {
                    data.status          = Utils.GetStatus(false);
                    data.error_code      = htPkg["error_code"].ToString();
                    data.error_full_desc = htPkg["error_desc"].ToString();
                    LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                    Console.WriteLine(data.error_full_desc);
                    return(data);
                }
                string pkgId = htPkg["package_id"].ToString();

                // 生成数据包文件
                Hashtable htPkgf = pkgService.CreateSkuPropsPackageFile(
                    appType, batId, pkgId, userId, null, items);
                if (!Convert.ToBoolean(htPkgf["status"]))
                {
                    data.status          = Utils.GetStatus(false);
                    data.error_code      = htPkgf["error_code"].ToString();
                    data.error_full_desc = htPkgf["error_desc"].ToString();
                    LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                    Console.WriteLine(data.error_full_desc);
                    return(data);
                }

                // 发布数据包
                Hashtable htPkgPublish = pkgService.PublishPackage(appType, batId, pkgId, userId);
                if (!Convert.ToBoolean(htPkgPublish["status"]))
                {
                    data.status          = Utils.GetStatus(false);
                    data.error_code      = htPkgPublish["error_code"].ToString();
                    data.error_full_desc = htPkgPublish["error_desc"].ToString();
                    LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                    Console.WriteLine(data.error_full_desc);
                    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);
                Console.WriteLine(data.error_full_desc);
            }
            return(data);
        }
Exemple #6
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);
        }
Exemple #7
0
        /// <summary>
        /// 获取日志集合接口
        /// </summary>
        public GetLogsContract GetLogs(TransType transType, string userId, string userPwd,
                                       long startRow, long rowsCount, LogQueryInfo queryInfo)
        {
            string    bizId     = Utils.NewGuid();
            string    methodKey = "LogService.GetLogs";
            string    ifCode    = "C011";
            var       data      = new GetLogsContract();
            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("start_row", startRow);
                htParams.Add("rows_count", rowsCount);
                htParams.Add("query_info", queryInfo);
                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 <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("密码", userPwd, 1, 32, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }

                // queryInfo
                htResult = ErrorService.CheckLength("日志ID", queryInfo.log_id, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("业务ID", queryInfo.biz_id, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("业务名称", queryInfo.biz_name, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("日志类型ID", queryInfo.log_type_id, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("日志类型代码", queryInfo.log_type_code, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("日志代码", queryInfo.log_code, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("日志内容", queryInfo.log_body, 0, 200, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("开始创建时间", queryInfo.create_time_begin, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("结束创建时间", queryInfo.create_time_end, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("创建人ID", queryInfo.create_user_id, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("开始修改时间", queryInfo.modify_time_begin, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("结束修改时间", queryInfo.modify_time_end, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("修改人ID", queryInfo.modify_user_id, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("客户代码", queryInfo.customer_code, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("客户ID", queryInfo.customer_id, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("门店代码", queryInfo.unit_code, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("门店ID", queryInfo.unit_id, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("用户代码", queryInfo.user_code, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("用户ID", queryInfo.user_id, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("接口代码", queryInfo.if_code, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                htResult = ErrorService.CheckLength("平台代码", queryInfo.app_code, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <GetLogsContract>(htResult));
                }
                #endregion

                Hashtable htQueryInfo = new Hashtable();
                htQueryInfo.Add("LogId", queryInfo.log_id);
                htQueryInfo.Add("BizId", queryInfo.biz_id);
                htQueryInfo.Add("BizName", queryInfo.biz_name);
                htQueryInfo.Add("LogTypeId", queryInfo.log_type_id);
                htQueryInfo.Add("LogTypeCode", queryInfo.log_type_code);
                htQueryInfo.Add("LogCode", queryInfo.log_code);
                htQueryInfo.Add("LogBody", queryInfo.log_body);
                htQueryInfo.Add("CreateTimeBegin", queryInfo.create_time_begin);
                htQueryInfo.Add("CreateTimeEnd", queryInfo.create_time_end);
                htQueryInfo.Add("CreateUserId", queryInfo.create_user_id);
                htQueryInfo.Add("ModifyTimeBegin", queryInfo.modify_time_begin);
                htQueryInfo.Add("ModifyTimeEnd", queryInfo.modify_time_end);
                htQueryInfo.Add("ModifyUserId", queryInfo.modify_user_id);
                htQueryInfo.Add("CustomerCode", queryInfo.customer_code);
                htQueryInfo.Add("CustomerId", queryInfo.customer_id);
                htQueryInfo.Add("UnitCode", queryInfo.unit_code);
                htQueryInfo.Add("UnitId", queryInfo.unit_id);
                htQueryInfo.Add("UserCode", queryInfo.user_code);
                htQueryInfo.Add("UserId", queryInfo.user_id);
                htQueryInfo.Add("IfCode", queryInfo.if_code);
                htQueryInfo.Add("AppCode", queryInfo.app_code);

                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();
                IList <LogInfo>       logs         = logDBService.GetLogs(htQueryInfo, startRow, rowsCount);
                if (logs != null)
                {
                    data.Logs = new List <LogContract>();
                    foreach (var log in logs)
                    {
                        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.Logs.Add(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);
        }
Exemple #8
0
        /// <summary>
        /// 用户凭证验证
        /// </summary>
        public ValidateContract Validate(TransType transType, string userCode,
                                         string customerCode, string password, string type)
        {
            string    bizId     = Utils.NewGuid();
            string    methodKey = "AuthService.Validate";
            string    ifCode    = "C003";
            var       data      = new ValidateContract();
            Hashtable htLogExt  = new Hashtable();

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

                bool      statusFlag = false;
                Hashtable htError    = null;
                string    userId     = string.Empty;
                string    token      = string.Empty;
                CertInfo  certInfo   = null;

                if (type == null || type == string.Empty)
                {
                    type = CertType.POS.ToString();
                }

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

                // 检查参数
                Hashtable htResult       = new Hashtable();
                bool      paramCheckFlag = false;
                #region Check Length
                htResult = ErrorService.CheckLength("用户代码", userCode, 1, 40, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <ValidateContract>(htResult));
                }
                htResult = ErrorService.CheckLength("用户密码", password, 1, 40, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <ValidateContract>(htResult));
                }

                if (type == CertType.POS.ToString())
                {
                    htResult = ErrorService.CheckLength("客户代码", customerCode, 1, 40, true, false, ref paramCheckFlag);
                    if (!paramCheckFlag)
                    {
                        return(ErrorConvert.Export <ValidateContract>(htResult));
                    }
                }
                else
                {
                    htResult = ErrorService.CheckLength("客户代码", customerCode, 0, 40, true, false, ref paramCheckFlag);
                    if (!paramCheckFlag)
                    {
                        return(ErrorConvert.Export <ValidateContract>(htResult));
                    }
                }
                #endregion

                // 查询用户或客户是否存在
                //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_desc = htError["error_desc"].ToString();
                //    LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId);
                //    return data;
                //}

                // 查询凭证
                Hashtable htCert = new Hashtable();
                htCert["UserCode"]     = userCode;
                htCert["CustomerCode"] = customerCode;
                htCert["CertPwd"]      = password;
                if (type == CertType.MOBILE.ToString())
                {
                    htCert["CustomerCode"] = null;
                    htCert["CertTypeCode"] = type.ToLower();
                }
                statusFlag = authService.Validate(htCert, ref certInfo);
                if (!statusFlag)
                {
                    htError = ErrorService.OutputError(ErrorCode.A009, "用户代码与密码/用户代码与客户代码不匹配", true);
                    if (type == CertType.MOBILE.ToString())
                    {
                        htError = ErrorService.OutputError(ErrorCode.A009, "用户代码与密码不匹配", true);
                    }
                    data.error_code      = htError["error_code"].ToString();
                    data.error_full_desc = htError["error_desc"].ToString();
                }
                else
                {
                    userId = certInfo.UserId;
                    // 获取令牌
                    var certTokenInfo = GetCertToken(certInfo.CertId, certInfo.UserId, true);
                    token               = certTokenInfo.CertToken;
                    data.user_id        = userId;
                    data.token          = token;
                    htLogExt["user_id"] = userId;
                }

                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(), null, htLogExt);
            }
            return(data);
        }
Exemple #9
0
        /// <summary>
        /// 修改用户密码接口
        /// </summary>
        public BaseContract ChangePassword(TransType transType,
                                           string userId, string token, string unitId, string newPassword)
        {
            string    bizId     = Utils.NewGuid();
            string    methodKey = "AuthService.ChangePassword";
            string    ifCode    = "C029";
            var       data      = new BaseContract();
            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("user_id", userId);
                htParams.Add("token", token);
                htParams.Add("unit_id", unitId);
                htParams.Add("new_password", newPassword);
                LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, null, htLogExt);

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

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

                // 检查参数
                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 <BaseContract>(htResult));
                }
                //htResult = ErrorService.CheckLength("令牌", token, 1, 32, true, false, ref paramCheckFlag);
                //if (!paramCheckFlag) return ErrorConvert.Export<BaseContract>(htResult);
                htResult = ErrorService.CheckLength("门店ID", unitId, 1, 32, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <BaseContract>(htResult));
                }
                htResult = ErrorService.CheckLength("用户新密码", newPassword, 1, 40, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    return(ErrorConvert.Export <BaseContract>(htResult));
                }
                #endregion

                // 检查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;

                // 提交
                var bsAuthService = new ServicesBs.AuthService();
                bsAuthService.ChangePassword(customerId, unitId, userId, newPassword);
                authService.UpdateCertPwdByUserId(userId, newPassword);

                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(), null, htLogExt);
            }
            return(data);
        }
Exemple #10
0
        public BaseContract Run(PackageGenTypeMethod packageGenType,
                                string batId, string customerId, string unitId, string userId)
        {
            AppType   appType   = AppType.BS;
            string    bizId     = Utils.NewGuid();
            string    methodKey = "Task.PackageUsers";
            string    ifCode    = TaskCode.T001.ToString();
            var       data      = new BaseContract();
            Hashtable htLogExt  = new Hashtable();

            htLogExt["customer_code"] = null;
            htLogExt["customer_id"]   = customerId;
            htLogExt["unit_code"]     = null;
            htLogExt["unit_id"]       = unitId;
            htLogExt["user_code"]     = null;
            htLogExt["user_id"]       = userId;
            htLogExt["if_code"]       = ifCode;
            htLogExt["app_code"]      = appType.ToString();
            try
            {
                Hashtable htParams = new Hashtable();
                htParams.Add("package_gen_type", packageGenType);
                htParams.Add("bat_id", batId);
                htParams.Add("customer_id", customerId);
                htParams.Add("unit_id", unitId);
                htParams.Add("user_id", userId);
                LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, userId, htLogExt);

                bool statusFlag = true;

                // 检查参数
                Hashtable htResult       = new Hashtable();
                bool      paramCheckFlag = false;
                #region Check Length
                htResult = ErrorService.CheckLength("客户ID", customerId, 1, 50, true, false, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    throw new Exception(string.Format("批次{0}:客户ID不能为空", batId));
                }
                htResult = ErrorService.CheckLength("门店ID", unitId, 0, 50, true, true, ref paramCheckFlag);
                if (!paramCheckFlag)
                {
                    throw new Exception(string.Format("批次{0}:门店ID不能为空", batId));
                }
                #endregion

                htLogExt["customer_id"] = customerId;

                // 循环生成数据包
                int count = 1000; // 获取总数量
                //int pageSize = 500; // 每页数量
                int num = 0;

                while (num <= count)
                {
                    ExchangeBsService.UserAuthService bsUserAuthService = new ExchangeBsService.UserAuthService();
                    cPos.Model.BaseInfo usersInfo = bsUserAuthService.GetUserBaseByUserId(userId, customerId, unitId);
                    string         pkgBatId       = Utils.NewGuid();
                    string         pkgTypeCode    = PackageTypeMethod.USERS.ToString();
                    string         pkgGenTypeCode = packageGenType.ToString();
                    PackageService pkgService     = new PackageService();
                    Hashtable      htPkg          = pkgService.CreatePackage(appType, pkgBatId, pkgTypeCode,
                                                                             customerId, unitId, userId, pkgGenTypeCode, null, null, AppType.POS.ToString());
                    if (!Convert.ToBoolean(htPkg["status"]))
                    {
                        data.status          = Utils.GetStatus(false);
                        data.error_code      = htPkg["error_code"].ToString();
                        data.error_full_desc = htPkg["error_desc"].ToString();
                        LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                        Console.WriteLine(data.error_full_desc);
                        return(data);
                    }
                    string    pkgId  = htPkg["package_id"].ToString();
                    Hashtable htPkgf = pkgService.CreateUsersProfilePackageFile(
                        AppType.Client, pkgBatId, pkgId, userId, null,
                        usersInfo.CurrMenuInfoList, usersInfo.CurrRoleInfoList,
                        usersInfo.CurrRoleMenuInfoList, usersInfo.CurrSalesUserInfoList,
                        usersInfo.CurrSalesUserRoleInfoList);
                    if (!Convert.ToBoolean(htPkgf["status"]))
                    {
                        data.status          = Utils.GetStatus(false);
                        data.error_code      = htPkgf["error_code"].ToString();
                        data.error_full_desc = htPkgf["error_desc"].ToString();
                        LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                        Console.WriteLine(data.error_full_desc);
                        return(data);
                    }
                    Hashtable htPkgPublish = pkgService.PublishPackage(AppType.Client, pkgBatId, pkgId, userId);
                    if (!Convert.ToBoolean(htPkgPublish["status"]))
                    {
                        data.status          = Utils.GetStatus(false);
                        data.error_code      = htPkgPublish["error_code"].ToString();
                        data.error_full_desc = htPkgPublish["error_desc"].ToString();
                        LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt);
                        Console.WriteLine(data.error_full_desc);
                        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);
                Console.WriteLine(data.error_full_desc);
            }
            return(data);
        }