/// <summary>
        /// Creates a deep copy of an <see cref="Analytic"/>.
        /// </summary>
        public static Analytic Copy(this Analytic source)
        {
            var copy = new Analytic();

            copy.SearchGroupKey = source.SearchGroupKey;

            DateTime createdDate = DateTime.Now;

            copy.Identity.Created   = createdDate;
            copy.Identity.Edited    = createdDate;
            copy.Identity.Refreshed = createdDate;
            copy.Identity.IsActive  = source.Identity.IsActive;
            copy.Identity.Author    = source.Identity.Author;

            string copySuffix = " (Copy)";

            copy.Identity.Description = source.Identity.Description + copySuffix;
            copy.Identity.Editor      = source.Identity.Editor;
            copy.Identity.Name        = source.Identity.Name + copySuffix;
            copy.Identity.Notes       = source.Identity.Notes + copySuffix;
            copy.Identity.Owner       = source.Identity.Owner;
            copy.Identity.Shared      = source.Identity.Shared;

            foreach (FilterGroup filterGroup in source.FilterGroups)
            {
                FilterGroup filterGroupCopy = filterGroup.Copy();
                copy.FilterGroups.Add(filterGroupCopy);
            }

            foreach (AnalyticValueDriver driver in source.ValueDrivers)
            {
                AnalyticValueDriver driverCopy = driver.Copy();
                copy.ValueDrivers.Add(driverCopy);
            }

            foreach (AnalyticPriceListGroup item in source.PriceListGroups)
            {
                AnalyticPriceListGroup priceListGroupCopy = item.Copy();
                copy.PriceListGroups.Add(priceListGroupCopy);
            }

            copy.IsDirty = true;

            return(copy);
        }
        /// <summary>
        /// Creates a copy of an <see cref="AnalyticValueDriver"/>.
        /// </summary>
        public static AnalyticValueDriver Copy(this AnalyticValueDriver source)
        {
            var copy = new AnalyticValueDriver();

            copy.Id         = source.Id;
            copy.IsSelected = source.IsSelected;
            copy.Key        = source.Key;
            copy.Name       = source.Name;
            copy.Sort       = source.Sort;

            foreach (AnalyticValueDriverMode mode in source.Modes)
            {
                copy.Modes.Add(mode.Copy());
            }
            if (source.SelectedMode != null)
            {
                copy.SelectedMode = copy.Modes.SingleOrDefault(m => m.Key == source.SelectedMode.Key);
            }

            return(copy);
        }
示例#3
0
 private void OnSelectedDriverChanged(AnalyticValueDriver driver)
 {
     this.RaisePropertyChanged("IsValueDriverSelected");
 }
        private static List <AnalyticValueDriver> GetAnalyticDrivers()
        {
            var result = new List <AnalyticValueDriver>();

            string[] driverNames = { "Markup", "Movement", "Days On Hand" };

            AnalyticValueDriver driver;

            for (int driverIndex = 0; driverIndex < driverNames.Length; driverIndex++)
            {
                var analyticResults = GetAnalyticResults(driverNames[driverIndex]);

                AnalyticValueDriverGroup group;
                driver = new AnalyticValueDriver {
                    Id = driverIndex + 21, Name = driverNames[driverIndex], Sort = (short)driverIndex, Results = analyticResults
                };
                //Auto generated
                var mode = new AnalyticValueDriverMode
                {
                    Name       = "Auto Generated groups",
                    Key        = 29,
                    Sort       = 0,
                    IsSelected = true
                };
                int minOutlier = 0;
                for (int groupIndex = 1; groupIndex <= 3; groupIndex++)
                {
                    minOutlier += 1;
                    group       = new AnalyticValueDriverGroup {
                        Id = groupIndex, Value = (short)groupIndex, MinOutlier = minOutlier, MaxOutlier = minOutlier + 1, Sort = (short)groupIndex
                    };
                    mode.Groups.Add(group);
                }
                driver.Modes.Add(mode);

                //User defined
                mode = new AnalyticValueDriverMode
                {
                    Name       = "User defined groups",
                    Key        = 30,
                    Sort       = 1,
                    IsSelected = false
                };
                minOutlier = 0;
                for (int groupIndex = 1; groupIndex <= 5; groupIndex++)
                {
                    minOutlier += 1;
                    group       = new AnalyticValueDriverGroup {
                        Id = groupIndex, Value = (short)groupIndex, MinOutlier = minOutlier, MaxOutlier = minOutlier + 1, Sort = (short)groupIndex
                    };
                    mode.Groups.Add(group);
                }
                driver.Modes.Add(mode);

                //Simulate mode and driver selections.
                driver.SelectedMode = driver.Modes[driverIndex % 2];
                driver.IsSelected   = (driverIndex % 2 == 0);

                result.Add(driver);
            }

            //Add in disabled "teaser" drivers for demo only.
            driver = new AnalyticValueDriver {
                Id = 97, Key = 37, Name = "Days Lead Time", IsDisplayOnly = true, Sort = 5
            };
            result.Add(driver);

            driver = new AnalyticValueDriver {
                Id = 99, Key = 38, Name = "In Stock Ratio", IsDisplayOnly = true, Sort = 6
            };
            result.Add(driver);

            driver = new AnalyticValueDriver {
                Id = 99, Key = 39, Name = "Trend", IsDisplayOnly = true, Sort = 7
            };
            result.Add(driver);

            return(result);
        }