Esempio n. 1
0
        /// <summary>
        /// 得到相似客户
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public List <CustomerResultDTO> GetSimilarCustomerList(CustomerSearchDTO dto)
        {
            List <CustomerResultDTO> result = null;
            var tcdmse = SingleQueryObject.GetObj();

            var all = tcdmse.master_CustomerInfo.AsNoTracking().Where(p => p.CustomerID != null);

            if (!string.IsNullOrEmpty(dto.SearchText))
            {
                List <string> dict  = new List <string>();
                int           count = (int)Math.Ceiling(dto.SearchText.Length / 2.0);
                for (int i = 1; i <= count; i++)
                {
                    if (i == count)
                    {
                        dict.Add(dto.SearchText.Substring((i - 1) * 2));
                    }
                    else
                    {
                        dict.Add(dto.SearchText.Substring((i - 1) * 2, 2));
                    }
                }
                var filted = tcdmse.master_CustomerInfo.AsNoTracking().Where(p => p.CustomerID == null);
                foreach (var di in dict)
                {
                    filted = filted.Union(all.Where(p => p.CustomerName.Contains(di)));
                }
                dto.Count = filted.Count();
                filted    = filted.OrderBy(m => m.CustomerName).ThenBy(m => m.CustomerID).Skip((dto.page - 1) * dto.rows).Take(dto.rows);
                result    = Mapper.Map <List <master_CustomerInfo>, List <CustomerResultDTO> >(filted.ToList());
            }

            return(result);
        }
Esempio n. 2
0
        public HttpResponseMessage GetCustomerList(string CustomerSearchDTO)
        {
            CustomerSearchDTO dto = TransformHelper.ConvertBase64JsonStringToDTO <CustomerSearchDTO>(CustomerSearchDTO);

            ResultDTO <List <CustomerResultDTO> > actionresult = new ResultDTO <List <CustomerResultDTO> >();

            try
            {
                if (dto.QueryType == 0)//查询客户信息
                {
                    actionresult.Object = _ICustomerServices.GetCustomerList(dto);
                }
                else if (dto.QueryType == 1)//查询相似客户
                {
                    actionresult.Object = _ICustomerServices.GetSimilarCustomerList(dto);
                }
                actionresult.SubmitResult = true;
                actionresult.rows         = dto.rows;
                actionresult.page         = dto.page;
                actionresult.Count        = dto.Count;
            }
            catch (Exception ex)
            {
                actionresult.SubmitResult = false;
                actionresult.Message      = ex.Message;
            }
            HttpResponseMessage result = new HttpResponseMessage
            {
                Content = new StringContent(JsonConvert.SerializeObject(actionresult),
                                            System.Text.Encoding.GetEncoding("UTF-8"),
                                            "application/json")
            };

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 得到启用的客户信息
        /// </summary>
        /// <returns></returns>
        public static ResultData <List <CustomerInfoModel> > GetIsActiveCustomerList(CustomerSearchDTO dto)
        {
            ResultData <List <CustomerInfoModel> > result = null;

            result = GetAPI <ResultData <List <CustomerInfoModel> > >(WebConfiger.MasterDataServicesUrl + "CustomerInfo?CustomerSearchDTO=" + TransformHelper.ConvertDTOTOBase64JsonString(dto));

            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// 得到客户信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public ActionResult GetCustomerList(CustomerSearchDTO dto)
        {
            ResultData <List <CustomerInfoModel> > result = new ResultData <List <CustomerInfoModel> >();

            result = CustomerProvider.GetCustomerList(dto);

            return(Json(new { total = result.Count, rows = result.Object }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        public void TestMethod1()
        {
            //客户信息.戴锐
            //新增

            CustomerSearchDTO adddto = new CustomerSearchDTO();

            adddto.page = 1;
            adddto.rows = 1;

            var dtostr = TransformHelper.ConvertDTOTOBase64JsonString(adddto);

            testcontroller.GetCustomerList(dtostr);
            CustomerOperateDTO adddtotest = new CustomerOperateDTO();

            adddtotest.CustomerName = "单元测试客户名称001";
            adddtotest.CustomerID   = Guid.NewGuid();
            var addresult = JsonConvert.DeserializeObject <ResultDTO <object> >(testcontroller.AddCustomer(adddtotest).Content.ReadAsStringAsync().Result);

            adddto.rows       = 10;
            adddto.SearchText = "单元测试客户名称001";
            dtostr            = TransformHelper.ConvertDTOTOBase64JsonString(adddto);
            var resultlist1 = JsonConvert.DeserializeObject <ResultDTO <List <CustomerResultDTO> > >(testcontroller.GetCustomerList(dtostr).Content.ReadAsStringAsync().Result).Object;
            var target      = resultlist1.Where(m => m.CustomerName == "单元测试客户名称001").FirstOrDefault();

            Assert.IsNotNull(target);

            //修改
            adddtotest.CustomerID   = target.CustomerID;
            adddtotest.CustomerName = "修改单元测试客户名称的002";
            adddtotest.UpType       = 1;
            var updateresult = JsonConvert.DeserializeObject <ResultDTO <object> >(testcontroller.UpdateCustomer(adddtotest).Content.ReadAsStringAsync().Result);

            adddto.SearchText = "修改单元测试客户名称的002";
            dtostr            = TransformHelper.ConvertDTOTOBase64JsonString(adddto);
            var resultlist2 = JsonConvert.DeserializeObject <ResultDTO <List <CustomerResultDTO> > >(testcontroller.GetCustomerList(dtostr).Content.ReadAsStringAsync().Result).Object;

            target = resultlist2.Where(m => m.CustomerName == "修改单元测试客户名称的002").FirstOrDefault();
            Assert.IsNotNull(target);

            //删除
            CustomerSearchDTO deletedto = new CustomerSearchDTO();

            deletedto.CustomerID = target.CustomerID;
            var deletedtostr = TransformHelper.ConvertDTOTOBase64JsonString(deletedto);
            var deleteresult = JsonConvert.DeserializeObject <ResultDTO <object> >(testcontroller.DeleteCustomer(deletedtostr).Content.ReadAsStringAsync().Result);
            var resultlist3  = JsonConvert.DeserializeObject <ResultDTO <List <CustomerResultDTO> > >(testcontroller.GetCustomerList(dtostr).Content.ReadAsStringAsync().Result).Object;

            target = resultlist3.Where(m => m.CustomerID == target.CustomerID).FirstOrDefault();
            Assert.IsNull(target);

            //停用
        }
Esempio n. 6
0
        public static CustomerSearchDTO ConvertToCustomerSearchDto(Customer customer)
        {
            CustomerSearchDTO customerSearchDTO = new CustomerSearchDTO();

            if (customerSearchDTO != null)
            {
                customerSearchDTO.CustomerId     = customer.CustomerId;
                customerSearchDTO.CustomerCodeId = customer.CustomerCode;
                customerSearchDTO.CustomerName   = customer.CustomerName;
            }

            return(customerSearchDTO);
        }
Esempio n. 7
0
        /// <summary>
        /// 得到一条客户信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static ResultData <CustomerInfoModel> GetCustomer(CustomerSearchDTO dto)
        {
            ResultData <CustomerInfoModel> result = new ResultData <CustomerInfoModel>();

            var resultlist = GetAPI <ResultData <List <CustomerInfoModel> > >(WebConfiger.MasterDataServicesUrl + "CustomerInfo?CustomerSearchDTO=" + TransformHelper.ConvertDTOTOBase64JsonString(dto));

            if (resultlist.Object != null && resultlist.Object.Count > 0)
            {
                result.Object       = resultlist.Object.First();
                result.SubmitResult = true;
            }
            else
            {
                result.Message = "此条信息不存在!";
            }

            return(result);
        }
Esempio n. 8
0
        /// <summary>
        /// 得到一条客户信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult GetCustomer(CustomerSearchDTO dto)
        {
            dto.page = 1;
            dto.rows = 10;
            ResultData <CustomerInfoModel> result = new ResultData <CustomerInfoModel>();

            try
            {
                result = CustomerProvider.GetCustomer(dto);
            }
            catch (Exception ex)
            {
                result.SubmitResult = false;
                result.Message      = ex.Message;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 9
0
        /// <summary>
        /// 导出客户信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public ActionResult ExportCustomer(CustomerSearchDTO dto)
        {
            dto.page = 1;
            dto.rows = 10000000;
            string result = null;

            List <CustomerInfoModel> pp = null;

            pp = CustomerProvider.GetCustomerList(dto).Object;

            string        strTemplateFile = Server.MapPath(@"~/TempLate/CustomerInfoTemplate.xlsx");
            string        strGenarateDir  = Server.MapPath(@"~/TempFile");
            string        strGenarateFile = Guid.NewGuid().ToString("N") + ".xlsx";
            string        strExportFile   = strGenarateDir + "\\" + strGenarateFile;
            List <object> ratelist        = new List <object>();

            pp.ForEach(g =>
            {
                Models.Model.Excel.ExcelCustomerInfo er = new Models.Model.Excel.ExcelCustomerInfo();
                er.状态         = g.Status;
                er.省份         = g.Province;
                er.城市         = g.City;
                er.新增时间       = g.CreateTime.HasValue ? g.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : null;
                er.Oracle号    = g.OracleNO;
                er.OracleName = g.OracleName;
                er.经销商提交客户名称  = g.CustomerName;
                er.携手网编号      = g.XSWNO;
                er.经销商名称      = g.DistributorName;
                er.审批人        = g.Auditor;
                er.最后修改人      = g.ModifyUser;
                ratelist.Add(er);
            });

            if (Common.ExcelHelper.Export(strTemplateFile, strGenarateDir, strGenarateFile, ratelist, "Sheet1"))
            {
                result = strGenarateFile;
            }

            return(Json(result));
        }
Esempio n. 10
0
        /// <summary>
        /// 得到客户信息列表(查询)
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public List <CustomerResultDTO> GetCustomerList(CustomerSearchDTO dto)
        {
            List <CustomerResultDTO> result = null;
            var tcdmse = SingleQueryObject.GetObj();

            var pp = tcdmse.master_CustomerInfo.AsNoTracking().Where(p => p.CustomerID != null);

            if (dto.CustomerID != null)
            {
                pp = pp.Where(p => p.CustomerID == dto.CustomerID);
            }
            else
            {
                if (!string.IsNullOrEmpty(dto.Province))
                {
                    pp = pp.Where(p => p.Province == dto.Province);
                    if (!string.IsNullOrEmpty(dto.City))
                    {
                        pp = pp.Where(p => p.City == dto.City);
                        if (!string.IsNullOrEmpty(dto.Country))
                        {
                            pp = pp.Where(p => p.Country == dto.Country);
                        }
                    }
                }
                if (!string.IsNullOrEmpty(dto.SearchText))
                {
                    pp = pp.Where(p => p.CustomerName.Contains(dto.SearchText) ||
                                  p.master_DistributorInfo.DistributorName.Contains(dto.SearchText));
                }
            }
            dto.Count = pp.Count();
            pp        = pp.OrderBy(m => m.CustomerName).ThenBy(m => m.CustomerID).Skip((dto.page - 1) * dto.rows).Take(dto.rows);
            result    = Mapper.Map <List <master_CustomerInfo>, List <CustomerResultDTO> >(pp.ToList());

            return(result);
        }
Esempio n. 11
0
        private bool CheckCustomer(object obj)
        {
            bool result           = true;
            CustomerSearchDTO dto = new CustomerSearchDTO();

            dto.rows = 100000000;
            string strimporter = ((UserLoginDTO)Session["UserLoginInfo"]).FullName;

            dto.page = 1;
            var CustomerList       = CustomerProvider.GetCustomerList(dto);
            var ProvinceRegionList = AreaRegionProvider.GetProvinceRegionList();
            List <ExcelCustomerInfoDTO> exceldto = (List <ExcelCustomerInfoDTO>)obj;

            foreach (var p in exceldto)
            {
                StringBuilder sb = new StringBuilder();
                if (String.IsNullOrEmpty(p.CustomerName))
                {
                    sb.Append("客户名称不能为空");
                }
                else
                {
                    var CustomerID = CustomerList.Object.Where(m => m.CustomerName == p.CustomerName).Select(m => m.CustomerID).FirstOrDefault();
                    if (CustomerID != null)
                    {
                        p.CustomerID = CustomerID;
                        p.UpLogic    = 2;
                    }
                    else
                    {
                        p.UpLogic = 1;
                    }
                }
                if (string.IsNullOrEmpty(p.XSWNO))
                {
                    sb.Append("携手网编号不可为空!");
                }
                if (string.IsNullOrEmpty(p.Province))
                {
                    sb.Append("省份不能为空!");
                }
                else
                {
                    var exist = ProvinceRegionList.Where(m => m.RegionName == p.Province).FirstOrDefault();
                    if (exist != null)
                    {
                        p.Province = exist.RegionName;
                    }
                    else
                    {
                        sb.Append("注册省份不存在!");
                    }
                }
                if (string.IsNullOrEmpty(p.City))
                {
                    sb.Append("城市不能为空!");
                }
                else
                {
                    var nextArea = GlobalStaticData.RegionList.Where(m => m.RegionName == p.City).FirstOrDefault();
                    if (nextArea == null)
                    {
                        sb.Append("注册城市" + p.City + "不存在!");
                    }
                    else
                    {
                    }
                }
                p.Importer = strimporter;
                if (sb.Length > 0)
                {
                    p.CheckInfo = sb.ToString();
                    result      = false;
                }
            }
            return(result);
        }
Esempio n. 12
0
        //#region MembriSovrascritti
        //[Secure(Area = "Contatti", Alias = "Visualizza contatto", MacroArea = "Applicativo")]
        //public void CheckSecurityForView()
        //{
        //    SecurityManager.Instance.Check();
        //}


        //[Secure(Area = "Contatti", Alias = "Inserisci contatto", MacroArea = "Applicativo")]
        //public void CheckSecurityForInsert()
        //{
        //    SecurityManager.Instance.Check();
        //}


        //[Secure(Area = "Contatti", Alias = "Aggiorna contatto", MacroArea = "Applicativo")]
        //public void CheckSecurityForUpdate()
        //{
        //    SecurityManager.Instance.Check();
        //}

        //[Secure(Area = "Contatti", Alias = "Elimina contatto", MacroArea = "Applicativo")]
        //public void CheckSecurityForDeletion()
        //{
        //    SecurityManager.Instance.Check();
        //}


        //public override AbstractPersistenceObject GetElementById(string id)
        //{
        //    CheckSecurityForView();
        //    return base.GetElementById(id);
        //}


        //public override void SaveOrUpdate(AbstractPersistenceObject element)
        //{
        //    if (element == null)
        //        return;

        //    if (element.Key == null)
        //        CheckSecurityForInsert();
        //    else
        //        CheckSecurityForUpdate();

        //    base.SaveOrUpdate(element);
        //}


        //public override void Delete(AbstractPersistenceObject element)
        //{
        //    CheckSecurityForDeletion();
        //    base.Delete(element);
        //}


        //public override IList GetAll()
        //{
        //    CheckSecurityForView();
        //    return base.GetAll();
        //}

//#endregion



        public IList SearchCustomers(CustomerSearchDTO dto)
        {
            //CheckSecurityForView();

            Query q = _ps.CreateNewQuery("MapperCustomer");

#if (FENEAL)
            q.SetTable("DB_UTENTE");
#else
            q.SetTable("App_Customers");
#endif
            q.SetMaxNumberOfReturnedRecords(dto.MaxResult);


            CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);


            if (!string.IsNullOrEmpty(dto.Descrizione))
            {
                c.AddCriteria(Criteria.Matches("COGNOME", dto.Descrizione, _ps.DBType));
            }

            if (!string.IsNullOrEmpty(dto.Responsable))
            {
                c.AddCriteria(Criteria.Matches("NOME", dto.Responsable, _ps.DBType));
            }

            if (dto.CheckPrivate)
            {
                if (dto.IsPrivate)
                {
                    c.AddCriteria(Criteria.Equal("IS_PRIVATO", "1"));
                }
                else
                {
                    c.AddCriteria(Criteria.Equal("IS_PRIVATO", "0"));
                }
            }


            if (!string.IsNullOrEmpty(dto.Cellulare))
            {
                c.AddCriteria(Criteria.Matches("CELL1", dto.Cellulare, _ps.DBType));
            }

            if (!string.IsNullOrEmpty(dto.Mail))
            {
                c.AddCriteria(Criteria.Matches("MAIL", dto.Mail, _ps.DBType));
            }

            if (!string.IsNullOrEmpty(dto.Piva))
            {
                c.AddCriteria(Criteria.Matches("CODICE_FISCALE", dto.Piva, _ps.DBType));
            }


            if (dto.Resource != null)
            {
                c.AddCriteria(Criteria.Equal("ResourceID", dto.Resource.Id.ToString()));
            }

            if (dto.Province != null)
            {
                if (dto.Province.Id != -1)
                {
                    c.AddCriteria(Criteria.Equal("ID_TB_PROVINCIE_RESIDENZA", dto.Province.Id.ToString()));
                }
            }

            if (dto.Comune != null)
            {
                if (dto.Comune.Id != -1)
                {
                    c.AddCriteria(Criteria.Equal("ID_TB_COMUNI_RESIDENZA", dto.Comune.Id.ToString()));
                }
            }



            q.AddWhereClause(c);

            string d = q.CreateQuery(_ps);

            return(q.Execute(_ps));
        }