示例#1
0
		static ManglerBase GetMangler(CFType type) {
			if (type == CFType.Switch)
				return Switch;
			return Jump;
		}
        internal static bool RequiresDxf(CFType type)
        {
            switch (type)
            {
                case CFType.IconSet:
                case CFType.ColorScale:
                case CFType.DataBar:
                    return false;

                default:
                    return true;
            }
        }
 public CFRule(CFType type, int priority = 1)
 {
     Priority = priority;
     Type = type;
     Operator = null;
     Formula1 = null;
     Formula2 = null;
     Formula3 = null;
     IsBottom = false;
     Rank = 10;
     IsPercent = false;
     StdDev = 0;
     IsAboveAverage = true;
     IsEqualAverage = false;
     IsStdDev = false;
     Text = null;
     TimePeriod = TimePeriod.Today;
 }
        public static string CreateFormula(string value, CFType type, string firstCell)
        {
            switch (type)
            {
                case CFType.ContainsText:
                    return string.Format(containsText, value, firstCell);

                case CFType.NotContainsText:
                    return string.Format(notContainsText, value, firstCell);

                case CFType.BeginsWith:
                    return string.Format(beginsWith, value, firstCell);

                case CFType.EndsWith:
                    return string.Format(endsWith, value, firstCell);

                case CFType.ContainsBlanks:
                    return string.Format(containsBlanks, firstCell);

                case CFType.NotContainsBlanks:
                    return string.Format(notContainsBlanks, firstCell);

                case CFType.ContainsErrors:
                    return string.Format(containsErrors, firstCell);

                case CFType.NotContainsErrors:
                    return string.Format(notContainsErrors, firstCell);

                default:
                    return value;
            }
        }
        public CFRule(CFType type, CellStyle style, CFOperator @operator = CFOperator.LessThan, 
            string formula1 = "", string formula2 = "", string formula3 = "")
        {
            Type = type;
            Style = style;
            Operator = @operator;
            Formula1 = formula1;
            Formula2 = formula2;
            Formula3 = formula3;
            IsBottom = false;
            Rank = 10;
            IsPercent = false;
            StdDev = 0;
            IsAboveAverage = true;
            IsEqualAverage = false;
            IsStdDev = false;

            Text = null;
            TimePeriod = TimePeriod.Today;
        }
        public CFRule AddGreaterThanOrEqual(string value, CellStyle style)
        {
            CFType type = CFType.CellIs;

            return(GetRuleForOneValue(type, value, style, CFOperator.GreaterThanOrEqual));
        }
        public CFRule AddLessThan(string value, CellStyle style)
        {
            CFType type = CFType.CellIs;

            return(GetRuleForOneValue(type, value, style, CFOperator.LessThan));
        }
        public static void Initialize(FinPlannerContext context)
        {
            context.Database.EnsureCreated();
            if (context.CFTypes.Any())
            {
                return;
            }
            var cfTypes = new CFType[]
            {
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Salary"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Rent"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Groceries"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Electricty"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Loans"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Car Loan"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Insurance"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Bank Charges"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Domestic"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Cellphone"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Gym"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Internet"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Medical Aid"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Entertainment"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Takeout"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "School Fees"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Transportation"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Medication"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = true, ClientReference = "999", Name = "Transfer"
                }
            };

            foreach (CFType item in cfTypes)
            {
                context.CFTypes.Add(item);
            }
            context.SaveChanges();
            if (context.CFClassifications.Any())
            {
                return;
            }
            var cfClass = new CFClassification[]
            {
                new CFClassification {
                    Id = Guid.NewGuid().ToString(), Name = "Income", Sign = 1
                },
                new CFClassification {
                    Id = Guid.NewGuid().ToString(), Name = "Expense", Sign = -1
                },
            };

            foreach (CFClassification item in cfClass)
            {
                context.CFClassifications.Add(item);
            }
            context.SaveChanges();
        }