public string GetTablesToExecute(string neededInfoJson) { var info = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, object> > >(neededInfoJson); // Partition the brands var brandsField = (Int64)info["brands"]["field"]; var brandsList = ((Newtonsoft.Json.Linq.JArray)info["brands"]["fieldItems"]).ToObject <List <int> >(); var b = SelectBrands(GetFieldByIndex((int)brandsField), brandsList); // Construct Spec SwitchSpec spec = new SwitchSpec { brands = { name = "abc", fieldItems = { 1, 2, 3, 4, 5 } }, period1Field = { name = null, fieldItems = { 3, 4, 5, 6 } } }; return(JsonConvert.SerializeObject(b)); }
public void SetSpec(SwitchSpec spec) { ClearSwitchingAnalysisSpec(); RollingGainLossCheckBox.Checked = spec.isRolling; if (spec.isRolling) { var t = PeriodListTask; } foreach (var field in typeof(SwitchSpec).GetFields()) { if (field.FieldType == typeof(FieldDetail)) { var dir = new Dictionary <string, wi.ListBoxItems.ListBox> { { "demographic", DemographicFieldBox }, { "period1", Period1Box }, { "period2", Period2Box }, { "data", DataFilterBox }, { "brands", BrandsBox }, { "primary", PrimaryVolumeBox }, { "secondary", SecondaryVolumeBox }, }; var keys = dir.Keys; var box = from key in keys where field.Name.ToLower().Contains(key.ToLower()) select dir[key]; if (box.Count() != 1) { throw new Exception("Internal Error: Unknown field in switch table spec " + field.Name); } var fieldValue = (FieldDetail)field.GetValue(spec); if (fieldValue.fieldName == null || fieldValue.fieldName.Length == 0) { continue; } mainWindow.SetField(fieldValue); var listItem = mainWindow.FieldListBox.Items.Find(x => x.Name == fieldValue.fieldName); listItem.Select(); Window.Mouse.DragAndDrop(listItem, box.First()); Window.HandleModelWindow(w => { w.Close(); return(true); }); } } RollingGainLossCheckBox.Checked = spec.isRolling; if (spec.isRolling) { SetPeriodInterval(spec.waveInterval); SetPeriodInterval(spec.waveInterval); SetPeriodLength(spec.periodLength); } }
public void Test() { //return; var fieldData = FieldFile.GetFieldFile("REP30040", DatabaseDir); SwitchSpec spec = new SwitchSpec { demographicField = new FieldDetail() { fieldName = "WPOCITY", fieldItems = { "全国总体", " 上海", " 北京", } }, period1Field = new FieldDetail() { fieldName = "W_PERIOD", fieldItems = new SortedSet <string>((from header in FieldFile.GetFieldFile("W_PERIOD", DatabaseDir).ReadFieldHeaders() select header.name).Skip(1).ToList()) }, dataFilter = new FieldDetail() { fieldName = "REP30031", fieldItems = { " 新鲜酸奶", " 果粒酸奶" } }, brands = new FieldDetail() { fieldName = "REP30040", fieldItemsIndex = new SortedSet <int> { 1, 2, 3 } }, primaryVolume = new FieldDetail() { fieldName = "R_SPEND", }, secondaryVolume = new FieldDetail() { fieldName = "R_SPEND", }, isRolling = true, periodLength = 13, waveInterval = 13, }; }