Exemplo n.º 1
0
 private Action AddDataTask <TValueObject, TResult>(IList <TValueObject> valueObjects, IConsumer consumer,
                                                    int workId)
 {
     return(() =>
     {
         _packageTasks.TryAdd(
             _packageService.CreatePackageTask(
                 _packageService.CreatePackage <TValueObject, TResult>(valueObjects, consumer, workId)));
     });
 }
Exemplo n.º 2
0
        public PackageId CreatePackage(DocumentPackage package)
        {
            Silanis.ESL.API.Package packageToCreate = package.ToAPIPackage();
            PackageId id = packageService.CreatePackage(packageToCreate);

            foreach (Document document in package.Documents.Values)
            {
                packageService.UploadDocument(id, document.FileName, document.Content, document.ToAPIDocument(packageToCreate));
            }

            return(id);
        }
Exemplo n.º 3
0
        public PackageId CreatePackage(DocumentPackage package)
        {
            ValidateSignatures(package);
            if (!IsSdkVersionSetInPackageData(package))
            {
                SetSdkVersionInPackageData(package);
            }

            Silanis.ESL.API.Package packageToCreate = new DocumentPackageConverter(package).ToAPIPackage();
            PackageId id = packageService.CreatePackage(packageToCreate);

            UploadDocuments(id, package.Documents);

            return(id);
        }
Exemplo n.º 4
0
        public PackageId CreatePackage(DocumentPackage package)
        {
            if (!IsSdkVersionSetInPackageData(package))
            {
                SetSdkVersionInPackageData(package);
            }

            Silanis.ESL.API.Package packageToCreate = new DocumentPackageConverter(package).ToAPIPackage();
            PackageId       id = packageService.CreatePackage(packageToCreate);
            DocumentPackage retrievedPackage = GetPackage(id);

            foreach (Document document in package.Documents.Values)
            {
                UploadDocument(document, retrievedPackage);
            }

            return(id);
        }
Exemplo n.º 5
0
        public PackageId CreatePackage(DocumentPackage package)
        {
            ValidateSignatures(package);
            if (!IsSdkVersionSetInPackageData(package))
            {
                SetSdkVersionInPackageData(package);
            }

            OneSpanSign.API.Package packageToCreate = new DocumentPackageConverter(package).ToAPIPackage();
            PackageId id = packageService.CreatePackage(packageToCreate);

            try
            {
                UploadDocuments(id, package.Documents);
            }
            catch (Exception e)
            {
                packageService.DeletePackage(id);
                throw new OssException("Could not create a new package." + " Exception: " + e.Message, e);
            }
            return(id);
        }
Exemplo n.º 6
0
        public void CreatePackage(HttpContextBase context)
        {
            var request      = context.Request;
            var stream       = request.Files.Count > 0 ? request.Files[0].InputStream : request.InputStream;
            var clonedStream = CloneStream(stream);
            var package      = new ZipPackage(clonedStream);        // provide a cloned stream because ZipPackage now dispose it

            var symbolFiles = package.GetFiles("lib").Where(f => Path.GetExtension(f.Path) == ".pdb").ToList();

            foreach (var symbolFile in symbolFiles)
            {
                ProcessSymbolFile(symbolFile, package);
            }

            if (IsSymbolPackage(package, symbolFiles))
            {
                symbolPackageService.CreatePackage(context);
            }
            else
            {
                packageService.CreatePackage(context);
            }
        }
Exemplo n.º 7
0
 public Package CreatePackage(Card[] cards)
 {
     if (Utils.GetSession(_sessionService, HttpRequest, HttpResponse) == null)
     {
         return(null);
     }
     cards.ToList().ForEach(x => x.SetTypes());
     if (cards == null || cards.Length != Package.PackageSize)
     {
         HttpResponse.SetContent($"No cards or not the right amount of cards! The right amount: {Package.PackageSize}.");
         HttpResponse.SetStatus(HttpStatus.Bad_Request);
         return(null);
     }
     foreach (var card in cards)
     {
         if (_cardService.CardExists(card.Id))
         {
             HttpResponse.SetContent($"Card with Id: {card.Id} already exists");
             HttpResponse.SetStatus(HttpStatus.Bad_Request);
             return(null);
         }
     }
     return(_packageService.CreatePackage(cards.ToArray()));
 }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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);
        }