Esempio n. 1
0
        //批量导入承运商
        public bool InsertCRMShipperExecl(GetCRMShippersByConditionRequest request)
        {
            bool IsSuccess = false;

            try
            {
                ShipperManagementAccessor accessor = new ShipperManagementAccessor();
                IsSuccess = accessor.InsertCRMShipperExecl(request.InsertShipper);
            }
            catch (Exception ex)
            {
                LogError(ex);
                IsSuccess = false;
            }

            return(IsSuccess);
        }
Esempio n. 2
0
        public ActionResult Index(QueryCRMShipperViewModel vm, int?PageIndex, string Action)
        {
            if (vm.PostedTransportModes != null && vm.PostedTransportModes.Any())
            {
                StringBuilder transportModeSB = new StringBuilder();
                vm.PostedTransportModes.Each((i, s) =>
                {
                    transportModeSB.Append(s).Append("|");
                });
                transportModeSB.Remove(transportModeSB.Length - 1, 1);
                vm.SearchCondition.TransportMode = transportModeSB.ToString();
            }

            if (vm.PostedProductTypes != null && vm.PostedProductTypes.Any())
            {
                StringBuilder postedProductTypesSB = new StringBuilder();
                vm.PostedProductTypes.Each((i, s) =>
                {
                    postedProductTypesSB.Append(s).Append("|");
                });
                postedProductTypesSB.Remove(postedProductTypesSB.Length - 1, 1);
                vm.SearchCondition.ProductType = postedProductTypesSB.ToString();
            }
            //查询导出
            var getCRMShippersByConditionRequest = new GetCRMShippersByConditionRequest();

            if (Action == "查询" || Action == "Index")
            {
                getCRMShippersByConditionRequest.SearchCondition = vm.SearchCondition;
                getCRMShippersByConditionRequest.PageSize        = UtilConstants.PAGESIZE;
                getCRMShippersByConditionRequest.PageIndex       = PageIndex ?? 0;
            }
            else if (Action == "导出")
            {
                getCRMShippersByConditionRequest.SearchCondition = vm.SearchCondition;
                getCRMShippersByConditionRequest.PageSize        = 0;
                getCRMShippersByConditionRequest.PageIndex       = 0;
            }

            var getCRMShippersByConditionResponse = new ShipperManagementService().GetCRMShippersByCondition(getCRMShippersByConditionRequest);


            if (getCRMShippersByConditionResponse.IsSuccess)
            {
                if (!string.IsNullOrEmpty(vm.SearchCondition.TransportMode))
                {
                    IList <SelectListItem> selectedtransportModeTypes = new List <SelectListItem>();
                    vm.SearchCondition.TransportMode.Split('|').Each((i, s) =>
                    {
                        selectedtransportModeTypes.Add(new SelectListItem()
                        {
                            Text = s, Value = s
                        });
                    });

                    vm.SelectedTransportModes = selectedtransportModeTypes;
                }

                if (!string.IsNullOrEmpty(vm.SearchCondition.ProductType))
                {
                    IList <SelectListItem> selectedProductTypes = new List <SelectListItem>();
                    vm.SearchCondition.ProductType.Split('|').Each((i, s) =>
                    {
                        selectedProductTypes.Add(new SelectListItem()
                        {
                            Text = s, Value = s
                        });
                    });

                    vm.SelectedProductTypes = selectedProductTypes;
                }

                vm.CRMShipperCollection = getCRMShippersByConditionResponse.Result.CRMShipperCollection;
                vm.PageIndex            = getCRMShippersByConditionResponse.Result.PageIndex;
                vm.PageCount            = getCRMShippersByConditionResponse.Result.PageCount;
                Session["ShipperCRM_SearchCondition"] = vm.SearchCondition;
                Session["ShipperCRM_PageIndex"]       = vm.PageIndex;

                if (Action == "导出")
                {
                    return(this.Export(getCRMShippersByConditionResponse.Result.CRMShipperCollection));
                }
            }

            return(View(vm));
        }
Esempio n. 3
0
        public Response <GetCRMShippersByConditionResponse> GetCRMShippersByCondition(GetCRMShippersByConditionRequest request)
        {
            Response <GetCRMShippersByConditionResponse> response = new Response <GetCRMShippersByConditionResponse>()
            {
                Result = new GetCRMShippersByConditionResponse()
            };

            if (request == null || request.SearchCondition == null)
            {
                ArgumentNullException ex = new ArgumentNullException("GetCRMShippersByCondition request");
                LogError(ex);
                response.ErrorCode = ErrorCode.Argument;
                response.Exception = ex;
                return(response);
            }

            try
            {
                ShipperManagementAccessor accessor = new ShipperManagementAccessor();
                int RowCount;
                if (request.PageSize > 0)
                {
                    response.Result.CRMShipperCollection = accessor.GetCRMShippersByCondition(request.SearchCondition, request.PageIndex, request.PageSize, out RowCount);
                    response.Result.PageCount            = RowCount % request.PageSize == 0 ? RowCount / request.PageSize : RowCount / request.PageSize + 1;
                    response.Result.PageIndex            = request.PageIndex;
                }
                else
                {
                    response.Result.PageIndex            = 0;
                    response.Result.PageCount            = 0;
                    response.Result.CRMShipperCollection = accessor.GetCRMShippersByConditionNoPaging(request.SearchCondition);
                }
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                LogError(ex);
                response.Exception = ex;
                response.IsSuccess = false;
                response.ErrorCode = ErrorCode.Technical;
            }

            return(response);
        }