/// <summary> /// 绑定Grid数据 /// </summary> private void BindGrid() { VendorRule rule = new VendorRule(); gridView1.GridControl.DataSource = rule.RShow(conditionstr, ProcessGrid.GetQueryField(gridView1)); gridView1.GridControl.Show(); }
/// <summary> /// 删除 /// </summary> public override void EntityDelete() { VendorRule rule = new VendorRule(); Vendor entity = GetVendor(); rule.RDelete(entity); }
private async Task <VendorRule> GetVendorRule(VendorRuleModel ruleModel, string ruleDefinition, Guid userId, RuleType ruleType, Vendor vendor) { var criterion = ruleModel.Criteria != null ? new RuleCriterion { Operator = ExpressionType.And.ToString(), Children = await GetRuleCriteria(ruleModel.Criteria) } : null; var ruleEntity = new Rule(userId) { Name = $"{vendor.Name}_{ruleType}_{ruleModel.Name}", Criterion = criterion, Definition = ruleDefinition, Type = ruleType }; var vendorRule = new VendorRule { Name = ruleModel.Name, Rule = ruleEntity }; return(vendorRule); }
public void BuildVendorCriterial_NumberOf_Rule_Criterions_Are_Less_Than_Vendor_Criterions_Return_Common_Criterions() { // Arrange var expectedData = new List <CriterionValueModel> { new CriterionValueModel() { FieldName = "CostType", Operator = "Equal", Text = "Production", Value = "Production" } }; var ruleCriterions = CreateListOfCriterions(); ruleCriterions.Remove(ruleCriterions.First()); var vendorCriteria = CreateListOfVendorCriteria(); VendorRule vr = new VendorRule() { RuleId = Guid.NewGuid() }; // Act var data = _pgVendorRuleBuilder.BuildVendorCriterial(ruleCriterions, vendorCriteria, vr); // Assert Assert.AreEqual(data.Count, expectedData.Count); }
public void BuildVendorCriterial_NumberOf_VendorRule_And_Vendor_Criterions_Are_The_Same() { // Arrange var expectedData = new List <CriterionValueModel> { new CriterionValueModel { FieldName = "BudgetRegion", Operator = "Equal", Text = "Greater China", Value = "GREATER CHINA AREA" }, new CriterionValueModel() { FieldName = "CostType", Operator = "Equal", Text = "Production", Value = "Production" } }; var ruleCriterions = CreateListOfCriterions(); var vendorCriteria = CreateListOfVendorCriteria(); VendorRule vr = new VendorRule() { RuleId = Guid.NewGuid() }; // Act var data = _pgVendorRuleBuilder.BuildVendorCriterial(ruleCriterions, vendorCriteria, vr); // Assert Assert.AreEqual(data.Count, expectedData.Count); }
/// <summary> /// 绑定Grid /// </summary> public override void BindGrid() { VendorRule rule = new VendorRule(); DataTable dt = rule.RShow(HTDataConditionStr, ProcessGrid.GetQueryField(gridView1).Replace("AddFlag", "0 AddFlag")); //if (FormListAID == (int)EnumVendorType.工厂) //{ // SetGrid(dt); //} gridView1.GridControl.DataSource = dt; gridView1.GridControl.Show(); }
/// <summary> /// 修改 /// </summary> public override void EntityUpdate() { VendorRule rule = new VendorRule(); Vendor entity = GetVendor(); VendorContact[] entityVendorContact = GetVendorContact(); VendorSaleOP[] entityVendorSaleOP = GetVendorSaleOP(); VendorAddress[] entityAddress = GetVendorAddress(); VendorNews[] entityNews = GetVendorNews(); ArrayList entityVendorType = GetEntityDtsVendorType(drpVendorTypeID); rule.RUpdate(entity, entityVendorContact, entityVendorSaleOP, entityAddress, entityNews, entityVendorType); }
protected async Task <Guid> CreateVendorVideoProductionRule() { const string vendorName = "Vendor1_Production_Rule"; const string audioCategory = "Video company"; var sapVendorCode = "S_ALR_87012011" + DateTime.Now.Millisecond; const string EuropeRegion = Constants.BudgetRegion.Europe; const string contentTypeVideo = Constants.ContentType.Video; const string productionType = Constants.ProductionType.FullProduction; var vendor = new Vendor { Name = vendorName, SapVendor = sapVendorCode, Categories = new List <VendorCategory>() }; var audioVendorCategory = new VendorCategory { Name = audioCategory, Vendor = vendor, HasDirectPayment = true, Currency = new Currency { Code = "USD", Description = "USD", Symbol = "s" }, }; var vendorRule1 = new VendorRule { Rule = GetRule(vendorName, false, EuropeRegion, contentTypeVideo, productionType, 0m, new PgPaymentRuleDefinition { DetailedSplit = true, Splits = new[] { new PgPaymentRuleDefinitionSplit { FASplit = 1m, FPSplit = 1m, OESplit = 0m, CostTotalName = Constants.CostSection.Production } } }), VendorCategory = audioVendorCategory }; EFContext.VendorRule.Add(vendorRule1); await EFContext.SaveChangesAsync(); return(vendorRule1.VendorCategory.VendorId); }
/// <summary> /// 新增 /// </summary> public override int EntityAdd() { VendorRule rule = new VendorRule(); Vendor entity = GetVendor(); VendorContact[] entityVendorContact = GetVendorContact(); VendorSaleOP[] entityVendorSaleOP = GetVendorSaleOP(); VendorAddress[] entityAddress = GetVendorAddress(); VendorNews[] entityNews = GetVendorNews(); ArrayList entityVendorType = GetEntityDtsVendorType(drpVendorTypeID); ItemAdd[] entityItemAdd = GetItemAdd(); VendorInvoiceDts[] entityInvoice = GetVendorInvoice(); rule.RAdd(entity, entityVendorContact, entityVendorSaleOP, entityAddress, entityNews, entityVendorType, entityItemAdd, entityInvoice); return(entity.ID); }
private async Task <Guid?> InitDpvData( string sapvendorNumber, string vendorName = "Test vendor 1", bool isAipe = false, string budgetRegion = "AAK (Asia)", string contentType = Constants.ContentType.Video, string productionType = Constants.ProductionType.FullProduction, string category = "Production company", decimal total = 0, PgPaymentRuleDefinition ruleDefinition = null ) { var rule = GetRule(vendorName, isAipe, budgetRegion, contentType, productionType, total, ruleDefinition); var vendor = new Vendor { Name = vendorName, SapVendor = sapvendorNumber, Categories = new List <VendorCategory>() }; var vendorCategory = new VendorCategory { Name = category, Vendor = vendor, HasDirectPayment = true, Currency = new Currency { Id = usdId, Code = "USD", Description = "USD", Symbol = "s" }, }; var vendorRule = new VendorRule { Rule = rule, VendorCategory = vendorCategory }; EFContext.VendorRule.Add(vendorRule); await EFContext.SaveChangesAsync(); return(vendorRule.VendorCategory.VendorId); }
protected async Task <Guid> CreateVendor() { const string vendorName = "Vendor1_MultipleCategories_MultipleRules"; const string musicCategory = "Music company"; const string audioCategory = "Audio company"; var sapVendorCode = "S_ALR_87012011" + DateTime.Now.Millisecond; const string chinaRegion = Constants.BudgetRegion.China; const string europeRegion = Constants.BudgetRegion.Europe; const string contentType1 = Constants.ContentType.Video; const string contentType2 = Constants.ContentType.Audio; const string productionType = Constants.ProductionType.FullProduction; var vendor = new Vendor { Name = vendorName, SapVendor = sapVendorCode, Categories = new List <VendorCategory>() }; var musicVendorCategory = new VendorCategory { Name = musicCategory, Vendor = vendor, HasDirectPayment = true, Currency = new Currency { Code = "USD", Description = "USD", Symbol = "s" }, }; var audioVendorCategory = new VendorCategory { Name = audioCategory, Vendor = vendor, HasDirectPayment = true }; var vendorRule1 = new VendorRule { Rule = GetRule(vendorName, false, chinaRegion, contentType1, productionType, 10000m, new PgPaymentRuleDefinition { Splits = new[] { new PgPaymentRuleDefinitionSplit { FASplit = 0.7m, OESplit = 0.2m, CostTotalName = Constants.CostSection.CostTotal } } }), VendorCategory = musicVendorCategory }; var vendorRule2 = new VendorRule { Rule = GetRule(vendorName, false, europeRegion, contentType2, productionType, 10000m, new PgPaymentRuleDefinition { Splits = new[] { new PgPaymentRuleDefinitionSplit { FASplit = 0.7m, OESplit = 0.4m, CostTotalName = Constants.CostSection.CostTotal } } }), VendorCategory = audioVendorCategory }; var vendorRule3 = new VendorRule { Rule = GetRule(vendorName, false, europeRegion, contentType2, productionType, 50000m, new PgPaymentRuleDefinition { Splits = new[] { new PgPaymentRuleDefinitionSplit { FASplit = 0.7m, OESplit = 0.5m, CostTotalName = Constants.CostSection.CostTotal } } }), VendorCategory = audioVendorCategory }; var vendorRule4 = new VendorRule { Rule = GetRule(vendorName, false, europeRegion, contentType2, productionType, 10000m, new PgPaymentRuleDefinition { Splits = new[] { new PgPaymentRuleDefinitionSplit { FASplit = 0.7m, OESplit = 0.3m, CostTotalName = Constants.CostSection.CostTotal } } }), VendorCategory = musicVendorCategory }; EFContext.VendorRule.Add(vendorRule1); EFContext.VendorRule.Add(vendorRule2); EFContext.VendorRule.Add(vendorRule3); EFContext.VendorRule.Add(vendorRule4); await EFContext.SaveChangesAsync(); return(vendorRule1.VendorCategory.VendorId); }
public List <CriterionValueModel> BuildVendorCriterial(List <RuleCriterion> criterions, Dictionary <string, CriterionModel> vendorCriteria, VendorRule vr) { var result = new List <CriterionValueModel>(); foreach (var c in criterions) { if (!vendorCriteria.ContainsKey(c.FieldName)) { continue; } var criterion = vendorCriteria[c.FieldName]; if (string.IsNullOrEmpty(c.TargetValue)) { throw new NullReferenceException($"TargetValue for Criterion in Rule {vr.RuleId} is null."); } if (criterion.Values != null && !criterion.Values.ContainsKey(c.TargetValue)) { throw new NullReferenceException($"Criterion value {c.TargetValue} in Rule {vr.RuleId} can not be found."); } result.Add(new CriterionValueModel { FieldName = c.FieldName, Operator = c.Operator, Value = c.TargetValue, Text = criterion.Type == CriterionType.Select ? criterion.Values[c.TargetValue] : c.TargetValue }); } return(result); }