public async Task <byte[]> GetAsync(CustomerSearch option, CancellationToken token = default(CancellationToken))
        {
            var companyTask = companyQueryProcessor.GetAsync(new CompanySearch {
                Id = option.CompanyId
            }, token);
            var appConTask     = applicationControlGetByCompanyQueryProcessor.GetAsync(option.CompanyId.Value, token);
            var masterLoadTask = customerQueryProcessor.GetAsync(option, token);

            await Task.WhenAll(companyTask, appConTask, masterLoadTask);

            var company = companyTask.Result.First();
            var appCon  = appConTask.Result;
            var items   = masterLoadTask.Result.ToList();

            if (!items.Any())
            {
                return(null);
            }

            var report = new CustomerAccountSectionReport();

            report.Name = "得意先台帳" + DateTime.Now.ToString("yyyyMMdd");
            report.SetBasicPageSetting(company.Code, company.Name);
            report.SetData(items,
                           appCon.UsePublishInvoice == 1,
                           appCon.UseReminder == 1);

            report.Run();

            return(report.Convert());
        }
Пример #2
0
        public ActionResult Index()
        {
            var custSearch = new CustomerSearch()
            {
                Id = "JKJK*"
            };
            string url      = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "api/Customer";
            string jsonData = JsonConvert.SerializeObject(custSearch);
            var    req      = HttpWebRequest.Create(url);

            req.Method      = "POST";
            req.ContentType = "application/json";

            byte[] jsonByteData = ASCIIEncoding.ASCII.GetBytes(jsonData.ToCharArray());

            var reqStream = req.GetRequestStream();

            reqStream.Write(jsonByteData, 0, jsonData.Length);
            var response   = req.GetResponse();
            var respStream = new StreamReader(response.GetResponseStream());

            string   responseJsonData = respStream.ReadToEnd();
            Customer customer         = JsonConvert.DeserializeObject <Customer>(responseJsonData);

            return(View(customer));
        }
        public void Test_NoRateLimiter_TooManyRequest_Error()
        {
            var connector = new CustomerConnector();

            connector.UseRateLimiter = false;

            FortnoxApiException error = null;
            int i;

            for (i = 0; i < 200; i++)
            {
                var searchSettings = new CustomerSearch();
                searchSettings.City = TestUtils.RandomString();
                try
                {
                    connector.Find(searchSettings);
                }
                catch (FortnoxApiException ex)
                {
                    error = ex;
                    break;
                }
            }

            //Assert
            //Assert.IsTrue(failed > 0);
            Console.WriteLine($@"Succesful requests: {i}");
            Assert.IsNotNull(error);
            Console.WriteLine(error.Message);
            Assert.IsTrue(error.Message.Contains("Too Many Requests"));

            Thread.Sleep(5 * 1000); //Sleep to cooldown/recover from "debt" (otherwise following tests will fail with TooManyRequests)
        }
Пример #4
0
        public void Test_issue73_async_non_blockable()
        {
            var connector      = new CustomerConnector();
            var searchSettings = new CustomerSearch();

            searchSettings.Limit = 2;

            var watch = new Stopwatch();

            watch.Start();

            var runningTasks = new List <Task <EntityCollection <CustomerSubset> > >();

            for (int i = 0; i < 40; i++)
            {
                runningTasks.Add(connector.FindAsync(searchSettings));
            }

            Console.WriteLine(@"Thread free after: " + watch.ElapsedMilliseconds);
            Assert.IsTrue(watch.ElapsedMilliseconds < 1000);

            watch.Start();
            foreach (var runningTask in runningTasks)
            {
                var result = runningTask.GetAwaiter().GetResult();
                Assert.IsNotNull(result);
            }
            watch.Stop();
            Console.WriteLine(@"Total time: " + watch.ElapsedMilliseconds);
        }
        public ActionResult Query(CustomerSearch search)
        {
            //System.Threading.Thread.Sleep(3000);
            var result = _customerService.Query(search);

            return(PartialView("_SingersSearch", result));
        }
Пример #6
0
        public CustomerObjBase SearchCustomer(CustomerSearch id)

        {
            UserManager userManager = new UserManager();

            return(userManager.SearchCustomer(id));
        }
        public IEnumerable <KeyValuePair <int, string> > Search(string customerName)
        {
            if (string.IsNullOrEmpty(customerName) || string.IsNullOrWhiteSpace(customerName))
            {
                yield return(new KeyValuePair <int, string>());
            }

            var search = new CustomerSearch(new LevenshteinDistance());

            IEnumerable <KeyValuePair <int, string> > values = new List <KeyValuePair <int, string> >();

            if (_customerRespository.Persistence == Persistence.SQL)
            {
                values = _customerRespository.All.Select(i => new KeyValuePair <int, string>(i.Id, i.Name)).ToList();
            }
            else if (_customerRespository.Persistence == Persistence.Graph)
            {
                var graph = _customerRespository.GraphClient;

                values = graph.Cypher.Match("(p:Customer)").Return(p => p.As <CustomerGraph.Node>()).Results
                         .Select(p => new KeyValuePair <int, string>((int)p.Id, p.Name));
            }

            foreach (var match in search.FindClosestMatches(customerName, values.Select(i => i.Value), 5))
            {
                yield return(new KeyValuePair <int, string>(values.First(c => c.Value == match).Key, match));
            }
        }
Пример #8
0
    public async Task Test_Paging()
    {
        const int large = 20;
        const int small = 5;

        var connector      = FortnoxClient.CustomerConnector;
        var searchSettings = new CustomerSearch();

        searchSettings.Limit     = large;
        searchSettings.SortBy    = Sort.By.Customer.CustomerNumber;
        searchSettings.SortOrder = Sort.Order.Ascending;

        var largeCustomerCollection = await connector.FindAsync(searchSettings); //get up to 'large' number of entities

        var totalCustomers = largeCustomerCollection.TotalResources;

        var neededPages      = GetNeededPages(Math.Min(totalCustomers, large), small);
        var mergedCollection = new List <CustomerSubset>();

        for (var i = 0; i < neededPages; i++)
        {
            searchSettings.Limit = small;
            searchSettings.Page  = i + 1;
            var smallCustomerCollection = await connector.FindAsync(searchSettings);

            mergedCollection.AddRange(smallCustomerCollection.Entities);
        }

        for (var i = 0; i < largeCustomerCollection.Entities.Count; i++)
        {
            Assert.AreEqual(largeCustomerCollection.Entities[i].CustomerNumber, mergedCollection[i].CustomerNumber);
        }
    }
Пример #9
0
        /// <summary>検索前にCustomerSearchデータを準備</summary>
        /// <returns>準備されたCustomerSearchModel</returns>
        private CustomerSearch CreateSearchCondition()
        {
            var customerSearch = new CustomerSearch();

            customerSearch.CompanyId        = Login.CompanyId;
            customerSearch.CustomerCodeFrom = txtCustomerCodeFrom.Text;
            customerSearch.CustomerCodeTo   = txtCustomerCodeTo.Text;
            if (txtClosingDay.Text != "")
            {
                customerSearch.ClosingDay = int.Parse(txtClosingDay.Text);
            }
            if (cmbShareTransferFee.SelectedIndex == -1)
            {
                customerSearch.ShareTransferFee = null;
            }
            else
            {
                customerSearch.ShareTransferFee = cmbShareTransferFee.SelectedIndex;
            }
            customerSearch.StaffCodeFrom = txtStaffCodeFrom.Text;
            customerSearch.StaffCodeTo   = txtStaffCodeTo.Text;
            customerSearch.UpdateAtFrom  = datUpdateAtFrom.Value;
            customerSearch.UpdateAtTo    = datUpdateAtTo.Value;

            return(customerSearch);
        }
Пример #10
0
 public async Task <List <CustomerDto> > Search(CustomerSearch search)
 {
     if (string.IsNullOrWhiteSpace(search.FirstName) && string.IsNullOrWhiteSpace(search.LastName) && string.IsNullOrWhiteSpace(search.Address))
     {
         return(_mapper.Map <List <Customer>, List <CustomerDto> >(await _repository.GetAllAsync()));
     }
     return(_mapper.Map <List <Customer>, List <CustomerDto> >(await _repository.Search(search)));
 }
Пример #11
0
 Customer[] getById(CustomerSearch query)
 {
     if (query?.Id != null)
     {
         return(executeWithLock(() => customers.Where(i => i.Id == query.Id).ToArray()));
     }
     return(null);
 }
Пример #12
0
        public async Task <ListResponse> Customer_SearchPaginated(int PageNumber, int PageSize) //CustomerSearch req)
        {
            CustomerSearch customerSearch = new CustomerSearch();

            customerSearch.PageNumber = PageNumber;
            customerSearch.PageSize   = PageSize;
            return(await _customerProvider.Customer_Search(customerSearch));
        }
Пример #13
0
 Customer[] getAll(CustomerSearch query)
 {
     if (query == null || (query.Id == null && query.Name == null))
     {
         return(executeWithLock(() => customers.ToArray()));
     }
     return(null);
 }
Пример #14
0
 public void LikeSearchParams()
 {
     var qry = new CustomerSearch(_sqlDb)
     {
         OrgId = 1, Search = "hello"
     };
     var results = qry.Execute();
 }
Пример #15
0
 Customer[] getByName(CustomerSearch query)
 {
     if (query?.Name != null)
     {
         return(executeWithLock(() => customers.Where(i => i.Name.StartsWith(query.Name)).ToArray()));
     }
     return(null);
 }
        public IEnumerable <Customer> FindBySearch(CustomerSearch customerSearch)
        {
            if (customerSearch == null)
            {
                return(FindAll());
            }

            return(_customerRepository.FindBySearch(customerSearch));
        }
Пример #17
0
        private void Export()
        {
            try
            {
                ZeroLeftPaddingWithoutValidated();

                var customerSearch = new CustomerSearch();
                customerSearch.CompanyId        = Login.CompanyId;
                customerSearch.CustomerCodeFrom = txtCustomerCodeFrom.Text;
                customerSearch.CustomerCodeTo   = txtCustomerCodeTo.Text;
                if (txtClosingDay.Text != "")
                {
                    customerSearch.ClosingDay = int.Parse(txtClosingDay.Text);
                }
                if (cmbShareTransferFee.SelectedIndex == -1)
                {
                    customerSearch.ShareTransferFee = null;
                }
                else
                {
                    customerSearch.ShareTransferFee = cmbShareTransferFee.SelectedIndex;
                }
                customerSearch.StaffCodeFrom = txtStaffCodeFrom.Text;
                customerSearch.StaffCodeTo   = txtStaffCodeTo.Text;
                customerSearch.UpdateAtFrom  = datUpdateAtFrom.Value;
                customerSearch.UpdateAtTo    = datUpdateAtTo.Value;

                if (!RequiredCheck())
                {
                    return;
                }

                ClearStatusMessage();

                if (rdoCustomerMaster.Checked)
                {
                    //得意先マスター
                    ExportCustomer(customerSearch);
                }
                else if (rdoRegistrationFee.Checked)
                {
                    // 得意先マスター登録手数料(エクスポート)
                    ExportRegistrationFee();
                }
                else
                {
                    // 歩引設定(エクスポート)
                    ExportDiscount(customerSearch);
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                DispStatusMessage(MsgErrExportError);
            }
        }
Пример #18
0
 public ActionResult CustomerSearch(CustomerSearch customerSearch)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     FindMatchingCustomers(customerSearch);
     return(View(customerSearch));
 }
Пример #19
0
        public void Test_Find()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            var testKeyMark = TestUtils.RandomString();

            ICustomerConnector connector = new CustomerConnector();
            var newCustomer = new Customer()
            {
                Name        = "TestCustomer",
                Address1    = "TestStreet 1",
                Address2    = "TestStreet 2",
                ZipCode     = "01010",
                City        = testKeyMark,
                CountryCode = "SE", //CountryCode needs to be valid
                Email       = "*****@*****.**",
                Type        = CustomerType.Private,
                Active      = false,
                Comments    = testKeyMark
            };

            //Add entries
            for (var i = 0; i < 5; i++)
            {
                connector.Create(newCustomer);
            }

            //Apply base test filter
            var searchSettings = new CustomerSearch();
            searchSettings.City = testKeyMark;
            var fullCollection = connector.Find(searchSettings);

            Assert.AreEqual(5, fullCollection.TotalResources);
            Assert.AreEqual(5, fullCollection.Entities.Count);
            Assert.AreEqual(1, fullCollection.TotalPages);

            //Apply Limit
            searchSettings.Limit = 2;
            var limitedCollection = connector.Find(searchSettings);

            Assert.AreEqual(5, limitedCollection.TotalResources);
            Assert.AreEqual(2, limitedCollection.Entities.Count);
            Assert.AreEqual(3, limitedCollection.TotalPages);

            //Delete entries
            foreach (var entry in fullCollection.Entities)
            {
                connector.Delete(entry.CustomerNumber);
            }

            #region Delete arranged resources
            //Add code to delete temporary resources
            #endregion Delete arranged resources
        }
Пример #20
0
        public async Task <byte[]> GetAsync(CustomerSearch option, CancellationToken token = default(CancellationToken))
        {
            var report = new CustomerSectionReport();

            return((await report.BuildAsync("得意先マスター一覧" + DateTime.Today.ToString("yyyyMMdd"),
                                            companyQueryProcessor.GetAsync(new CompanySearch {
                Id = option.CompanyId
            }, token),
                                            customerQueryProcessor.GetAsync(option, token)))?.Convert());
        }
Пример #21
0
        public PagedResponse <CustomerDto> Execute(CustomerSearch search)
        {
            var query = context.Customers.AsQueryable();

            if (!string.IsNullOrEmpty(search.Name) || !string.IsNullOrWhiteSpace(search.Name))
            {
                query = query.Where(x => x.FirstName.ToLower().Contains(search.Name.ToLower()));
            }

            return(query.Paged <CustomerDto, Domain.Customers>(search, _mapper));
        }
Пример #22
0
        public override async Task ListCustomers(CustomerSearch request, IServerStreamWriter <Customer> responseStream, ServerCallContext context)
        {
            var customers = new List <Customer> {
                new Customer(), new Customer()
            };

            foreach (var customer in customers)
            {
                await responseStream.WriteAsync(customer);
            }
        }
Пример #23
0
        public Customer Post(CustomerSearch model)
        {
            var cust = new Customer
            {
                Id        = Guid.NewGuid(),
                FirstName = "Adam",
                LastName  = "Smith"
            };

            return(cust);
        }
Пример #24
0
        /// <summary>
        /// 查询客户列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public IPagedList <CustomerDetailModel> Query(CustomerSearch search)
        {
            var _session = HttpContext.Current.Session;

            if (int.Parse(_session["Authority"].ToString()) > 0)
            {
                var employeeId = _session["EmployeeId"]?.ToString();
                search.EmployeeId = Guid.Parse(employeeId);
            }
            return(_customerInfoRepository.Query(search));;
        }
Пример #25
0
        public PagedList <CUST_INFO_EX> QueryCustomerList(CustomerSearch search, PageView view, int org_id, int region_id)
        {
            string cols     = @"A.[ID],A.[STORE_ID],B.[NAME] as STORE_NAME,A.[CUST_NO]
                          ,A.[NAME],A.[IMAGE_ID],A.[GENDER],A.[BIRTHDAY],A.[IDTYPE],A.[IDCARD],A.[MOBILE],A.[COUNTRY]
	                      ,A.[PROVINCE],A.[CITY],A.[REGION],A.[ADDRESS],A.[ZIPCODE],A.[EDUCATION],A.[EMAIL]
                          ,A.[SOURCE],A.[QQ],A.[WECHAT],A.[FACEBOOK],A.[WEIBO],A.[OPTIN_SMS]
                          ,A.[INCOME],A.[POSITION],A.[WORK_STATION],A.[CREATE_DATE],A.[CREATE_USER]
                          ,A.[LAST_MODI_DATE],A.[LAST_MODI_USER],A.[CARD_NO],A.[PASSWORD],A.[TYPE],C.balance BALANCE,d.name CARD_NAME";
            string sqlWhere = " AND A.NAME!='散客'";

            if (!string.IsNullOrEmpty(search.NAME))
            {
                sqlWhere += " AND A.[NAME] LIKE '%" + search.NAME + "%'";
            }
            else
            {
                if (search.STORE_ID > 0)
                {
                    sqlWhere += " AND (A.[STORE_ID]='" + search.STORE_ID + "'  or  A.[STORE_ID] is  null)";
                }
                //if (org_id > 0 && region_id == 0)
                //{
                //    sqlWhere += " AND (A.[STORE_ID] in (select B.ID from ORG_STORE where B.ORG_ID=" + org_id + ")  or  A.[STORE_ID] is  null)";
                //}

                if (region_id > 0)
                {
                    sqlWhere += " AND (A.[STORE_ID] in (select C.ID  from ORG_STORE C  left join ORG_INFO D on  C.REGION_ID =D.ID where D.ID=" + region_id + " and C.ORG_ID=" + org_id + ")  or  A.[STORE_ID] is  null)";
                }
            }
            if (!string.IsNullOrEmpty(search.IDCARD))
            {
                sqlWhere += " AND A.[IDCARD] LIKE '%" + search.IDCARD + "%'";
            }
            if (!string.IsNullOrEmpty(search.MOBILE))
            {
                sqlWhere += " AND A.[MOBILE] LIKE '%" + search.MOBILE + "%'";
            }


            if (!string.IsNullOrEmpty(search.CARD_NO))
            {
                sqlWhere += " AND A.[CARD_NO]='" + search.CARD_NO + "'";
            }

            sqlWhere += " AND A.ORG_ID =" + search.ORG_ID;
            return(base.PageGet <CUST_INFO_EX>(view, cols,
                                               "[CUST_INFO] A  LEFT JOIN [ORG_STORE] B ON A.[STORE_ID]=B.ID left join   CUST_CARD c on a.id=c.Cust_id and c.CARD_TYPE=1 and c.STATUS=1  left join PROD_CARD d on c.CARD_ID=d.ID " //table
                                               , sqlWhere
                                               , "A.ID DESC ",
                                               ""));
            //ORDER BY A.[LAST_MODI_DATE] DESC
        }
Пример #26
0
        public IList<Customer> Any(CustomerSearch search)
        {
            // Example retrieving using OrmLite
            //if (search.Ids != null && search.Ids.Length > 0)
            //    return Db.GetByIds<Customer>(search.Ids);

            // Example retrieving using Redis
            if (search.Ids != null && search.Ids.Length > 0)
                return Redis.As<Customer>().GetByIds(search.Ids);

            return Redis.As<Customer>().GetAll();
        }
Пример #27
0
 public CustomerManager(CustomerResourceManager crm, Fleet fleet)
 {
     _crm   = crm;
     _fleet = fleet;
     AddCustomer.Submitted += AddCustomerOnSubmitted;
     CustomerSearch.GetComponent <Form>("initial search").Submitted += CustomerSearchOnSearch;
     CustomerSearch.GetComponent <Form>("customer list").Submitted  += CustomerSearchOnSearch;
     ModifyCustomer.GetComponent <Form>("search").Submitted         += ModifyCustomerOnSearch;
     ModifyCustomer.GetComponent <Form>("modify").Submitted         += ModifyCustomerOnSubmitted;
     DeleteCustomer.GetComponent <Form>("select").Submitted         += DeleteCustomerOnSearch;
     DeleteCustomer.GetComponent <Form>("confirm").Submitted        += DeleteCustomerOnSubmitted;
     CustomerReport.PreRender += CustomerReportOnFocused;
 }
Пример #28
0
        /// <summary>
        /// Method to check the validation while fetching the customer
        /// </summary>
        /// <param name="listResponse"></param>
        /// <param name="customerSearch"></param>
        /// <returns></returns>
        private ListResponse ValidateCustomerSearch(ListResponse listResponse, CustomerSearch customerSearch)
        {
            if (customerSearch.PageNumber <= 0)
            {
                listResponse.SetError(ErrorCodes.INVALID_PAGE_NO_Required);
            }

            if (customerSearch.PageSize <= 0)
            {
                listResponse.SetError(ErrorCodes.INVALID_PAGE_SIZE_Required);
            }

            return(listResponse);
        }
Пример #29
0
        public IEnumerable <Customer> FindBySearch(CustomerSearch customerSearch)
        {
            var result = _dbContext.Customer.AsQueryable();

            if (!string.IsNullOrEmpty(customerSearch.Name))
            {
                result = result.Where(x => x.Name.Contains(customerSearch.Name));
            }
            if (customerSearch.Gender != null)
            {
                result = result.Where(x => x.Gender == customerSearch.Gender);
            }
            if (customerSearch.Classification != null)
            {
                result = result.Where(x => x.Classification == customerSearch.Classification);
            }
            if (customerSearch.CityId != null)
            {
                result = result.Where(x => x.City.Id == customerSearch.CityId);
            }
            if (customerSearch.LastPurchase != null)
            {
                result = result.Where(x => x.LastPurchase >= customerSearch.LastPurchase);
            }
            if (customerSearch.Until != null)
            {
                result = result.Where(x => x.LastPurchase <= customerSearch.Until);
            }
            if (customerSearch.RegionId != null)
            {
                if (_dbContext.City.Find(customerSearch.CityId).RegionId != customerSearch.RegionId)
                {
                    result = result.Where(x => x.City.RegionId == customerSearch.RegionId || x.CityId == customerSearch.CityId);
                }
                else
                {
                    result = result.Where(x => x.City.RegionId == customerSearch.RegionId);
                }
            }
            if (customerSearch.SellerId != null)
            {
                result = result.Where(x => x.OwnerId == customerSearch.SellerId);
            }

            result
            .Include(model => model.Owner)
            .Include(model => model.City)
            .Include(model => model.City.Region);
            return(result);
        }
Пример #30
0
        /// <summary>
        /// Provider for api to search guest data
        /// </summary>
        /// <returns></returns>
        public async Task <ListResponse> Customer_Search(CustomerSearch customerSearch)
        {
            ListResponse listResponse = new ListResponse();

            if (customerSearch != null)
            {
                listResponse = ValidateCustomerSearch(listResponse, customerSearch);
                if (listResponse.HasError)
                {
                    return(listResponse);
                }
            }
            return(await _customerHandler.Customer_Search(customerSearch));
        }
Пример #31
0
        private void CustomerSearchOnSearch(object sender, Form.SubmittedEventArgs e)
        {
            var options = _crm.Customers.Select(c => new[]
            {
                new Tuple <string, Customer>(c.Id.ToString(), c),
                new Tuple <string, Customer>(c.Title.ToString(), c),
                new Tuple <string, Customer>(c.GivenNames, c),
                new Tuple <string, Customer>(c.Surname, c),
                new Tuple <string, Customer>(c.Gender.ToString(), c)
            }).SelectMany(it => it).ToArray();

            if (e.Data.Get <string>("Search").IsEmpty())
            {
                e.Result = "Enter a search term";
                return;
            }

            var parser = new MrrcParser(e.Data.Get <string>("Search").ToUpperInvariant());
            var result = parser.Parse(parser.Tokenise());

            if (result is FailedParseResult <Expression> failure)
            {
                e.Result = failure.Message;
                return;
            }

            var success = (SuccessfulParseResult <Expression>)result;

            var matches = success.Result.Matches(options);

            var individualMatches = matches.Item1
                                    .Select(it => it.Item2)
                                    .Distinct()
                                    .Where(it => !matches.Item2.Contains(it))
                                    .ToArray();

            if (individualMatches.Length == 0)
            {
                e.Result = "No results where found";
                return;
            }

            var customerList = CustomerSearch.GetComponent <Form>("customer list");

            customerList.Set("Search", e.Data.Get <string>("Search"));
            customerList.GetComponent <Select>("Results")
            .SetNewMembers(individualMatches.Select(m => m.ToString()).ToArray());

            CustomerSearch.ActiveComponent = "customer list";
        }
    private void GenerateReport()
    {
        try
        {

            DataSet dsCustReport = new DataSet();
            CustomerSearch supSearch = new CustomerSearch();
            supSearch.FromDate = dtpFromDate.Date;
            supSearch.ToDate = dtpToDate.Date;
            supSearch.CustId = Int32.Parse(ddlCustomers.SelectedValue.ToString());
            dsCustReport = new CustomerDAO().GetTransactionHistoryByCustomer(supSearch);

            Session["CustomerFullReport"] = dsCustReport;
            BindGrid();
        }
        catch (Exception ex)
        {

            throw ex;
        }
    }
Пример #33
0
 public CustomerSearch CustomerNameSearch(string custName)
 {
     CustomerSearch custSearch = new CustomerSearch();
     SearchStringField customerEntityID = new SearchStringField();
     customerEntityID.@operator = SearchStringFieldOperator.@is;
     customerEntityID.operatorSpecified = true;
     customerEntityID.searchValue = custName;
     CustomerSearchBasic custBasic = new CustomerSearchBasic();
     custBasic.entityId = customerEntityID;
     custSearch.basic = custBasic;
     return custSearch;
 }
Пример #34
0
        public void setCustomer(string customerID)
        {
            NetSuiteService service = new NetSuiteService();
            service.CookieContainer = new CookieContainer();
            NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168");
            Passport passport = user.prepare(user);
            Status status = service.login(passport).status;

            CustomerSearch customerSearch = new CustomerSearch();
            customerSearch = CustomerNameSearch(customerID);
            SearchResult searchResult = service.search(customerSearch);
            if (searchResult.status.isSuccess)
            {
                if (searchResult.recordList != null && searchResult.recordList.Length == 1)
                {
                    string entityID = ((Customer)searchResult.recordList[0]).entityId;
                    Console.WriteLine(entityID);
                }
            }
            else
            {
                throw new Exception("Cannot find Customer " + customerID + " " + searchResult.status.statusDetail[0].message);
            }

            this.salesOrder.entity = createCustomer(searchResult);
        }
Пример #35
0
 public IList<Customer> OnCustomerSearch(ISession session, CustomerSearch e)
 {
     return new Expression().List<Models.Customers, Customer>();
 }
Пример #36
0
        public static RecordRef GetCustomer(string strParent, string strPhone)
        {
            RecordRef objCustomer = null;
            CustomerSearch custSearch = new CustomerSearch();
            SearchStringField customerPhone = new SearchStringField();
            customerPhone.@operator = SearchStringFieldOperator.@is;
            customerPhone.operatorSpecified = true;
            customerPhone.searchValue = strPhone;

            CustomerSearchBasic custBasic = new CustomerSearchBasic();
            custBasic.phone = customerPhone;
            custBasic.parent = new SearchMultiSelectField();
            custBasic.parent.@operator = SearchMultiSelectFieldOperator.anyOf;
            custBasic.parent.operatorSpecified = true;
            custBasic.parent.searchValue = new RecordRef[1];
            custBasic.parent.searchValue[0] = new RecordRef();
            custBasic.parent.searchValue[0].internalId = strParent;
            custBasic.parent.searchValue[0].type = RecordType.customer;
            custBasic.parent.searchValue[0].typeSpecified = true;

            custSearch.basic = custBasic;

            SearchResult res = _service.search(custSearch);
            if (res.status.isSuccess)
            {
                if (res.recordList != null && res.recordList.Length == 1)
                {
                    objCustomer = new RecordRef();
                    objCustomer.type = RecordType.customer;
                    objCustomer.typeSpecified = true;
                    System.String entID = ((Customer)(res.recordList[0])).entityId;
                    objCustomer.name = entID;
                    objCustomer.internalId = ((Customer)(res.recordList[0])).internalId;
                }
            }

            return objCustomer;
        }
Пример #37
0
        public static Customer GetCustomer(string strCustomerName)
        {
            RecordRef reseller = new RecordRef();
            Customer objCustomer = new Customer();
            try
            {
                CustomerSearch custSearch = new CustomerSearch();
                custSearch.basic = new CustomerSearchBasic();
                custSearch.basic.entityId = new SearchStringField();
                custSearch.basic.entityId.@operator = SearchStringFieldOperator.@is;
                custSearch.basic.entityId.operatorSpecified = true;
                custSearch.basic.entityId.searchValue = strCustomerName;

                SearchResult res = _service.search(custSearch);
                if (res.status.isSuccess)
                {
                    if (res.recordList != null && res.recordList.Length == 1)
                    {
                        reseller.type = RecordType.customer;
                        reseller.typeSpecified = true;
                        System.String entID = ((Customer)(res.recordList[0])).entityId;
                        reseller.name = entID;
                        reseller.internalId = ((Customer)(res.recordList[0])).internalId;

                        ReadResponse objReadResponse = _service.get(reseller);
                        if (objReadResponse.status.isSuccess)
                        {
                            objCustomer = (Customer)objReadResponse.record;
                        }
                    }
                }
            }
            catch (Exception objExc)
            {
            }

            return objCustomer;
        }