Changeset 6247 for branches/WebApplication/MVC2/HLWebOKBQueryPlugin
- Timestamp:
- 05/22/11 21:01:58 (14 years ago)
- Location:
- branches/WebApplication/MVC2/HLWebOKBQueryPlugin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/FilterController.cs
r6245 r6247 20 20 /// </summary> 21 21 /// <returns></returns> 22 public ActionResultGetRuns()22 public void GetRuns() 23 23 { 24 24 FilterModel qm = new FilterModel(); … … 32 32 Response.Write("Found <" + ids.Count() + "> Runs."); 33 33 34 return View("Index", qm); // name of usercontrol34 // return View("Index", qm); // name of usercontrol 35 35 } 36 36 … … 51 51 /// <param name="collection"></param> 52 52 /// <returns></returns> 53 public ActionResult AddFilterAnd( FormCollection collection)53 public ActionResult AddFilterAnd(string submitButton, FormCollection collection) 54 54 { 55 55 FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]); 56 56 57 58 // Add Filter 59 String idKey = null; 60 String parentIdKey = null; 61 62 foreach (string key in collection.AllKeys) 63 { 64 if (key.StartsWith(FilterModel.ComboboxName)) 65 { 66 idKey = key; 67 } 68 if (key.StartsWith(FilterModel.ParentIdName)) 69 { 70 parentIdKey = key; 71 } 72 } 73 74 Guid parentId = new Guid(collection.Get(parentIdKey)); 75 string filterTypeName = collection.Get(idKey); 76 fm.AddFilter(filterTypeName, parentId); 77 57 Response.Write("Submit:" + submitButton); 58 59 //update model with form data 78 60 UpdateModel(collection, fm); 79 61 62 if (submitButton.StartsWith("+")) 63 { 64 string stringid = submitButton.Substring(2); 65 AddNewFilter(collection, fm, stringid); 66 } 67 else if (submitButton.StartsWith("-")) 68 { 69 string stringid = submitButton.Substring(2); 70 DeleteFilter(new Guid(stringid)); 71 } 72 else if (submitButton.Equals("runs")) 73 { 74 GetRuns(); 75 } 76 else if (submitButton.Equals("or")) 77 { 78 AddFilterOr( fm); 79 } 80 80 81 // Set Content 81 82 Session["Content"] = fm.Content; 82 83 83 84 return View("Index", fm); 85 86 } 87 88 private void AddNewFilter(FormCollection collection, FilterModel fm, String idKey) 89 { 90 // Add Filter 91 //String idKey = null; 92 String parentIdKey = idKey; 93 94 //foreach (string key in collection.AllKeys) 95 //{ 96 // //if (key.StartsWith(FilterModel.ComboboxName)) 97 // //{ 98 // // idKey = key; 99 // //} 100 // if (key.StartsWith(FilterModel.ParentIdName)) 101 // { 102 // parentIdKey = key; 103 // } 104 //} 105 106 Guid parentId = new Guid(parentIdKey); 107 string filterTypeName = collection.Get(FilterModel.ComboboxName+ "." + idKey); 108 fm.AddFilter(filterTypeName, parentId); 109 110 //UpdateModel(collection, fm); 111 112 //// Set Content 113 //Session["Content"] = fm.Content; 114 115 //return View("Index", fm); 84 116 } 85 117 … … 111 143 { 112 144 int idx = key.IndexOf("."); 113 string id = key.Substring(0, idx); 114 string type = key.Substring(idx + 1); 115 116 Guid fid = new Guid(id); 117 118 if (postValues.ContainsKey(fid)) 145 if (idx != -1) 119 146 { 120 Dictionary<string, string> d = postValues[fid]; 121 d.Add(type, collection.Get(key)); 122 } 123 else 124 { 125 Dictionary<string, string> d = new Dictionary<string, string>(); 126 d.Add(type, collection.Get(key)); 127 postValues.Add(fid, d); 147 string id = key.Substring(0, idx); 148 string type = key.Substring(idx + 1); 149 150 Guid fid = new Guid(id); 151 152 if (postValues.ContainsKey(fid)) 153 { 154 Dictionary<string, string> d = postValues[fid]; 155 d.Add(type, collection.Get(key)); 156 } 157 else 158 { 159 Dictionary<string, string> d = new Dictionary<string, string>(); 160 d.Add(type, collection.Get(key)); 161 postValues.Add(fid, d); 162 } 128 163 } 129 164 } … … 140 175 /// <param name="id"></param> 141 176 /// <returns></returns> 142 public ActionResult DeleteFilter(Guid id)177 public void DeleteFilter(Guid id) 143 178 { 144 179 // Get Content from Session 145 180 FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]); 146 181 182 //throw new Exception(); 183 147 184 // Remove Filter 148 185 bool filterRemoved = fm.RemoveFilter(id); 149 186 187 188 //UpdateModel(collection, fm); 150 189 // TODO Model muss auch beim löschen upgeadatet werden UpdateModel(collection, fm); 151 190 152 191 // Set Content 153 Session["Content"] = fm.Content;154 155 return View("Index", fm);192 //Session["Content"] = fm.Content; 193 194 //return View("Index", fm); 156 195 } 157 196 … … 163 202 /// </summary> 164 203 /// <returns></returns> 165 public ActionResult AddFilterOr() 166 { 167 FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]); 168 204 public void AddFilterOr(FilterModel fm) 205 { 206 169 207 List<Filter> orFilters = fm.Content.Filters.ToList<Filter>(); ; 170 208 … … 177 215 Session["Content"] = fm.Content; 178 216 179 return View("Index", fm);217 //return View("Index", fm); 180 218 } 181 219 -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/ViewModels/FilterModel.cs
r6245 r6247 16 16 public class FilterModel 17 17 { 18 18 19 19 20 20 … … 61 61 } 62 62 63 public static List<ComparisonItem> OrdinalComparisons 63 public static List<ComparisonItem> OrdinalComparisons 64 64 { 65 65 get { return ComparisonsHelper.ordinalComparisons; } … … 70 70 get { return ComparisonsHelper.stringComparisons; } 71 71 } 72 73 74 72 73 74 75 75 76 76 /// <summary> … … 192 192 if (dict != null) 193 193 { 194 194 195 195 foreach (KeyValuePair<string, string> kvp in dict) 196 196 { 197 197 if ("StringComparisonFilter".Equals(f.GetType().Name)) 198 { 198 { 199 199 if (kvp.Key.Equals(FilterModel.ValueTextbox)) 200 200 { … … 202 202 } 203 203 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 204 { 205 ((StringComparisonFilter)f).Comparison = ComparisonsHelper.GetStringComparisonForValue(kvp.Value); 206 } 204 { 205 ((StringComparisonFilter)f).Comparison = ComparisonsHelper.GetStringComparisonForValue(kvp.Value); 206 } 207 207 } 208 208 else if ("NameStringComparisonFilter".Equals(f.GetType().Name)) … … 238 238 ((NameStringComparisonAvailableValuesFilter)f).Comparison = ComparisonsHelper.GetStringComparisonForValue(kvp.Value); 239 239 } 240 } 241 242 { 243 //TODO not supported244 } 245 240 } 241 else if ("NameEqualityComparisonByteArrayFilter".Equals(f.GetType().Name)) 242 { 243 //TODO not supported 244 } 245 else if ("NameEqualityComparisonBoolFilter".Equals(f.GetType().Name)) 246 246 { 247 247 if (kvp.Key.Equals(FilterModel.ValueDropDownList)) 248 248 { 249 ((NameEqualityComparisonBoolFilter)f).Value = Boolean.Parse( kvp.Value);249 ((NameEqualityComparisonBoolFilter)f).Value = Boolean.Parse(kvp.Value); 250 250 } 251 251 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) … … 268 268 } 269 269 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 270 { 271 ((NameOrdinalComparisonIntFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value); 270 { 271 ((NameOrdinalComparisonIntFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value); 272 272 } 273 273 } … … 286 286 } 287 287 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 288 { 289 ((NameOrdinalComparisonLongFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value); 290 } 291 } 292 288 { 289 ((NameOrdinalComparisonLongFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value); 290 } 291 } 293 292 else if ("NameOrdinalComparisonFloatFilter".Equals(f.GetType().Name)) 294 293 { … … 305 304 } 306 305 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 307 { 306 { 308 307 ((NameOrdinalComparisonFloatFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value); 309 308 } 310 309 } 310 else if ("OrdinalComparisonDateTimeFilter".Equals(f.GetType().Name)) 311 { 312 if (kvp.Key.Equals(FilterModel.ValueTextbox)) 313 { 314 try 315 { 316 ((OrdinalComparisonDateTimeFilter)f).Value = DateTime.Parse(kvp.Value); 317 } 318 catch (Exception) 319 { 320 //TOOD Fehler ausgeben 321 } 322 } 323 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 324 { 325 ((OrdinalComparisonDateTimeFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value); 326 } 327 } 311 328 else if ("NameOrdinalComparisonDoubleFilter".Equals(f.GetType().Name)) 312 329 { … … 323 340 } 324 341 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 325 { 342 { 326 343 ((NameOrdinalComparisonDoubleFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value); 327 344 } 328 345 } 329 346 330 347 331 348 else … … 334 351 } 335 352 336 353 337 354 } 338 339 355 356 340 357 } 341 358 } -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Filter/Filters.ascx
r6245 r6247 9 9 <p> 10 10 <% 11 CombinedFilter currentFilter = ((FilterModel)Model).Content;11 CombinedFilter topFilter = ((FilterModel)Model).Content; 12 12 %> 13 <% using (Html.BeginForm("AddFilterAnd", "Filter", FormMethod.Post, new { id = currentFilter.Id, name = currentFilter.Id })) %> 14 <% { %> 15 <% 16 17 string comboboxName = FilterModel.ComboboxName + "." + currentFilter.Id; 18 string hiddenName = FilterModel.ParentIdName + "." + currentFilter.Id; 13 <% using (Html.BeginForm("AddFilterAnd", "Filter", FormMethod.Post, new { id = topFilter.Id, name = topFilter.Id })) %> 14 <% { 15 16 foreach (Filter fNode in topFilter.Filters) 17 { 18 19 CombinedFilter currentFilter = (CombinedFilter)fNode; 20 string comboboxName = FilterModel.ComboboxName + "." + currentFilter.Id; 21 string hiddenName = FilterModel.ParentIdName + "." + currentFilter.Id; 19 22 %> 20 21 23 <%: Html.Hidden(hiddenName,currentFilter.Id.ToString()) %> 22 24 <%: Html.DropDownList( comboboxName, new SelectList(((FilterModel)Model).AvailableFilterForCombobox, "FilterTypeName", "Label"))%> 23 <input type="submit" value="+" />25 <input type="submit" name="submitButton" value="+.<%:currentFilter.Id%>" /> 24 26 </p> 25 27 <!-- Build the selected filters. The filtesr will be stored in the session and the … … 106 108 <%: Html.DropDownList(f.Id + "." + FilterModel.ComparisonDropDownList, new SelectList(FilterModel.OrdinalComparisons, "Value", "Text", (int)filter.Comparison))%> 107 109 <%: Html.TextBox(f.Id + "." + FilterModel.ValueTextbox, filter.Value)%> 110 <% } 111 else if ("OrdinalComparisonDateTimeFilter".Equals(f.GetType().Name)) 112 { %> 113 <% OrdinalComparisonDateTimeFilter filter = ((OrdinalComparisonDateTimeFilter)f); %> 114 <%: Html.Label(filter.Label)%> 115 <%: Html.DropDownList(f.Id + "." + FilterModel.ComparisonDropDownList, new SelectList(FilterModel.OrdinalComparisons, "Value", "Text", (int)filter.Comparison))%> 116 <%: Html.TextBox(f.Id + "." + FilterModel.ValueTextbox, filter.Value)%> 108 117 <% } 109 118 110 119 %> 111 <%: Html.ActionLink("remove", "DeleteFilter", new { f.Id })%>112 120 121 <input type="submit" name="submitButton" value="-.<%:f.Id%>" /> 122 113 123 <% }%> 114 124 </td></tr></table> 115 125 <% } %> 116 126 <% }%> 127 <% }%> 128 <input type="submit" name="submitButton" value="or" /> 129 </br> 130 <input type="submit" name="submitButton" value="runs" /> 131 132 133 117 134 <% } 118 135 -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Filter/Index.aspx
r6170 r6247 26 26 if (model != null && model.Content != null) 27 27 { 28 foreach (Filter f in model.Content.Filters)29 {28 29 FilterModel fm = new FilterModel((CombinedFilter)model.Content); 30 30 %> 31 32 <% FilterModel fm = new FilterModel((CombinedFilter)f);33 31 <% Html.RenderPartial("Filters", fm); %> 32 <% 33 } 34 34 %> 35 <% Html.RenderPartial("Filters", fm); %>36 <%}37 }%>38 35 39 36 40 37 41 <% using (Html.BeginForm("AddFilterOr", "Filter")) %> 42 <% { %> 43 Or filter <input type="submit" value="+" /> 44 <% } %> 38 45 39 46 40 47 41 48 <% using (Html.BeginForm("GetRuns", "Filter")) %> 49 <% { %> 50 <input type="submit" value="get runs" /> 51 <% } %> 42 52 43 53 44 </asp:Content>
Note: See TracChangeset
for help on using the changeset viewer.