Beispiel #1
0
        private List <Customer> BuildCustomerList(List <CommerceEntity> organizations)
        {
            var customers = new System.Collections.Concurrent.BlockingCollection <Customer>();
            Dictionary <string, Dsr>    dsrDict  = RetrieveDsrDictionary();
            Dictionary <string, string> termDict = RetrieveTermsCodeDict();

            System.Threading.Tasks.Parallel.ForEach(organizations, e => {
                Organization org = new KeithLink.Svc.Core.Models.Generated.Organization(e);

                if (org.OrganizationType == ORGANIZATION_TYPE_CUSTOMER)
                {
                    Customer myCustomer = org.ToCustomer();

                    string termKey = GetTermKey(org.BranchNumber, org.TermCode);

                    if (termDict.ContainsKey(termKey))
                    {
                        myCustomer.TermDescription = termDict[termKey];
                    }

                    string dsrKey = GetDsrKey(myCustomer.CustomerBranch, myCustomer.DsrNumber);
                    Dsr myDsr     = null;

                    if (dsrDict.ContainsKey(dsrKey))
                    {
                        myDsr = dsrDict[dsrKey];
                    }
                    else
                    {
                        dsrKey = GetDsrKey(myCustomer.CustomerBranch, DEFAULT_DSR_NUMBER);
                        if (dsrDict.ContainsKey(dsrKey))
                        {
                            myDsr = dsrDict[dsrKey];
                        }
                    }

                    myCustomer.Dsr = myDsr;

                    customers.Add(myCustomer);
                }
            });

            return(customers.ToList());
        }
        public List <Account> GetAccounts()
        {
            var queryOrg = new CommerceServer.Foundation.CommerceQuery <KeithLink.Svc.Core.Models.Generated.Organization>("Organization");

            queryOrg.SearchCriteria.WhereClause = "u_organization_type = '1'"; // org type of account

            CommerceQueryOperationResponse res = (Svc.Impl.Helpers.FoundationService.ExecuteRequest(queryOrg.ToRequest())).OperationResponses[0] as CommerceQueryOperationResponse;

            var accounts = new System.Collections.Concurrent.BlockingCollection <Account>();

            System.Threading.Tasks.Parallel.ForEach(res.CommerceEntities, e =>
            {
                KeithLink.Svc.Core.Models.Generated.Organization org = new KeithLink.Svc.Core.Models.Generated.Organization(e);
                accounts.Add(new Account()
                {
                    Id   = Guid.Parse(org.Id),
                    Name = org.Name,
                });
            });

            return(accounts.ToList());
        }