public void EnrichWithExternalData(PageXml content, PageData externalData, IRepository repository,
                                           ICrmService crmService, int salesOrders, bool addCustomerDetails, ILocationService locationService)
        {
            // enrich with  externalData other than customer


            if (externalData.CustomerData != null)
            {
                // enrich with externalData.CustomerData
            }
            else
            {
                CustomerInfo customerData = crmService.GetCustomerInfo(content.Customer.Name);
            }

            if (salesOrders > 0)
            {
                var orders = repository.GetEntities <Order>()
                             .Where(o => o.Customer.CompanyName == content.Customer.Name)
                             .OrderBy(o => o.OrderDate)
                             .Take(salesOrders);

                //enrich with orders
            }
        }
Beispiel #2
0
        public PageXml GetPageForOrders(IEnumerable <Order> orders, ICrmService crmService, ILocationService locationService)
        {
            string customerName = GetCustomerNameFromFirstOrder();

            PageXml content = new PageXml {
                Customer = new CustomerXml {
                    Name = customerName
                }
            };

            if (crmService != null)
            {
                CustomerInfo customerData = crmService.GetCustomerInfo(content.Customer.Name);
                //enrich with data from crm
            }

            //enrich content with orders

            if (locationService != null)
            {
                foreach (var address in content.Customer.Addresses)
                {
                    Coordinates coordinates = locationService.GetCoordinates(address.City, address.Street, address.Number);
                    if (coordinates != null)
                    {
                        address.Coordinates = string.Format("{0},{1}", coordinates.Latitude, coordinates.Longitude);
                    }
                }
            }

            return(content);
        }
Beispiel #3
0
        public bool ExportOrders(int maxSalesOrders, string customerName)
        {
            string fileName = string.Format("CustomerOrders-{0}-{1}.xml", customerName, DateTime.Now);
            string filePath = Path.Combine(exportFolder, fileName);

            PageXml content = new PageXml {
                Customer = new CustomerXml {
                    Name = customerName
                }
            };

            var orders = repository.GetEntities <Order>()
                         .Where(o => o.Customer.CompanyName == content.Customer.Name)
                         .OrderBy(o => o.OrderDate)
                         .Take(maxSalesOrders);

            //enrich content with orders

            XmlSerializer serializer = new XmlSerializer(typeof(PageXml));

            using (StreamWriter sw = File.CreateText(filePath))
            {
                serializer.Serialize(sw, content);
            }
            return(true);
        }
Beispiel #4
0
        public bool ExportCustomerPage(string fileNamePrefix, bool overwrite,
                                       string customerName, int maxSalesOrders, bool addCustomerDetails)
        {
            string fileName = string.Format("{0}-{1}.xml", fileNamePrefix, customerName);
            string filePath = Path.Combine(exportFolder, fileName);

            if (!overwrite && File.Exists(filePath))
            {
                return(false);
            }


            PageXml content = new PageXml {
                Customer = new CustomerXml {
                    Name = customerName
                }
            };

            if (maxSalesOrders > 0)
            {
                var orders = repository.GetEntities <Order>()
                             .Where(o => o.Customer.CompanyName == content.Customer.Name)
                             .OrderBy(o => o.OrderDate)
                             .Take(maxSalesOrders);

                //enrich content with orders
            }

            if (addCustomerDetails)
            {
                var customer = repository.GetEntities <Customer>()
                               .Where(c => c.CompanyName == customerName);

                // enrich content with customer data
            }


            XmlSerializer serializer = new XmlSerializer(typeof(PageXml));

            using (StreamWriter sw = File.CreateText(filePath))
            {
                serializer.Serialize(sw, content);
            }
            return(true);
        }
 public void Enrich(PageXml content, IRepository repository, int salesOrder, bool addCustomerDetails)
 {
 }
Beispiel #6
0
        public bool ExportCustomerPageWithExternalData(string fileNamePrefix, bool overwrite,
                                                       string customerName, int maxSalesOrders, bool addCustomerDetails,
                                                       PageData externalData, ICrmService crmService, ILocationService locationService)
        {
            string fileName = string.Format("{0}-{1}.xml", fileNamePrefix, customerName);
            string filePath = Path.Combine(exportFolder, fileName);

            if (!overwrite && File.Exists(filePath))
            {
                return(false);
            }


            PageXml content = new PageXml {
                Customer = new CustomerXml {
                    Name = customerName
                }
            };

            if (externalData.CustomerData != null)
            {
                // enrich with externalData.CustomerData
            }
            else
            {
                CustomerInfo customerData = crmService.GetCustomerInfo(content.Customer.Name);
            }

            if (maxSalesOrders > 0)
            {
                var orders = repository.GetEntities <Order>()
                             .Where(o => o.Customer.CompanyName == content.Customer.Name)
                             .OrderBy(o => o.OrderDate)
                             .Take(maxSalesOrders);

                //enrich content with orders
            }

            if (addCustomerDetails)
            {
                var customer = repository.GetEntities <Customer>()
                               .Where(c => c.CompanyName == customerName);

                // enrich content with customer data
            }

            if (locationService != null)
            {
                foreach (var address in content.Customer.Addresses)
                {
                    Coordinates coordinates = locationService.GetCoordinates(address.City, address.Street, address.Number);
                    if (coordinates != null)
                    {
                        address.Coordinates = string.Format("{0},{1}", coordinates.Latitude, coordinates.Longitude);
                    }
                }
            }


            XmlSerializer serializer = new XmlSerializer(typeof(PageXml));

            using (StreamWriter sw = File.CreateText(filePath))
            {
                serializer.Serialize(sw, content);
            }
            return(true);
        }