- Timestamp:
- 05/21/11 16:13:05 (14 years ago)
- Location:
- branches/WebApplication/MVC2/HLWebOKBQueryPlugin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/FilterController.cs
r6190 r6245 57 57 58 58 // Add Filter 59 60 59 String idKey = null; 61 60 String parentIdKey = null; … … 77 76 fm.AddFilter(filterTypeName, parentId); 78 77 79 80 81 82 78 UpdateModel(collection, fm); 79 80 // Set Content 81 Session["Content"] = fm.Content; 82 83 return View("Index", fm); 84 } 85 86 private void UpdateModel(FormCollection collection, FilterModel fm) 87 { 83 88 // Iterate "posted" values and build up a dictionary for 84 89 // each filter (id). 85 90 // <id> => <key> => <value> 86 91 // => <key> => <value> 92 Dictionary<Guid, Dictionary<string, string>> postValues = CreatePostValueMap(collection); 93 94 // Update filters with posted data 95 fm.UpdateWithPostValues(postValues); 96 } 97 98 99 // Iterate "posted" values and build up a dictionary for 100 // each filter (id). 101 // <id> => <key> => <value> 102 // => <key> => <value> 103 private Dictionary<Guid, Dictionary<string, string>> CreatePostValueMap(FormCollection collection) 104 { 87 105 Dictionary<Guid, Dictionary<string, string>> postValues = new Dictionary<Guid, Dictionary<string, string>>(); 88 106 … … 111 129 } 112 130 } 113 114 // Update filters with posted data 115 fm.UpdateWithPostValues(postValues); 116 117 118 // Set Content 119 Session["Content"] = fm.Content; 120 121 122 123 return View("Index", fm); 131 return postValues; 124 132 } 125 133 … … 139 147 // Remove Filter 140 148 bool filterRemoved = fm.RemoveFilter(id); 149 150 // TODO Model muss auch beim löschen upgeadatet werden UpdateModel(collection, fm); 141 151 142 152 // Set Content … … 163 173 fm.Content.Filters = orFilters.ToArray<Filter>(); 164 174 175 // TODO Model muss auch beim löschen upgeadatet werden UpdateModel(collection, fm); 165 176 166 177 Session["Content"] = fm.Content; -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/ViewModels/ComparisonsHelper.cs
r6191 r6245 22 22 private static String STRING_COMPARISONS_NOT_LIKE = "not like"; 23 23 24 private static String BOOL_COMPARISONS_EQUAL = "="; 25 private static String BOOL_COMPARISONS_NOT_EQUAL = "<>"; 26 27 public static List<ComparisonItem> boolComparisons = new List<ComparisonItem>() 28 { new ComparisonItem((int)OKBQueryService.EqualityComparison.Equal, BOOL_COMPARISONS_EQUAL), 29 new ComparisonItem((int)OKBQueryService.EqualityComparison.NotEqual, BOOL_COMPARISONS_NOT_EQUAL) 30 }; 24 31 public static List<ComparisonItem> ordinalComparisons = new List<ComparisonItem>() 25 32 { new ComparisonItem((int)OKBQueryService.OrdinalComparison.Less, ORDINAL_COMPARISONS_LESS), … … 40 47 41 48 42 public static String GetValueForStringComparision(OKBQueryService.StringComparison comparisionValue) 43 { 44 switch (comparisionValue) 45 { 46 case OKBQueryService.StringComparison.Equal: 47 return STRING_COMPARISONS_EQUAL; 48 case OKBQueryService.StringComparison.Contains: 49 return STRING_COMPARISONS_CONTAINS; 50 case OKBQueryService.StringComparison.Like: 51 return STRING_COMPARISONS_LIKE; 52 case OKBQueryService.StringComparison.NotContains: 53 return STRING_COMPARISONS_NOT_CONTAINS; 54 case OKBQueryService.StringComparison.NotEqual: 55 return STRING_COMPARISONS_NOT_EQUAL; 56 case OKBQueryService.StringComparison.NotLike: 57 return STRING_COMPARISONS_NOT_LIKE; 58 default: 59 return STRING_COMPARISONS_EQUAL; //TODO 60 } 61 } 49 //public static String GetValueForStringComparision(OKBQueryService.StringComparison comparisionValue) 50 //{ 51 // switch (comparisionValue) 52 // { 53 // case OKBQueryService.StringComparison.Equal: 54 // return STRING_COMPARISONS_EQUAL; 55 // case OKBQueryService.StringComparison.Contains: 56 // return STRING_COMPARISONS_CONTAINS; 57 // case OKBQueryService.StringComparison.Like: 58 // return STRING_COMPARISONS_LIKE; 59 // case OKBQueryService.StringComparison.NotContains: 60 // return STRING_COMPARISONS_NOT_CONTAINS; 61 // case OKBQueryService.StringComparison.NotEqual: 62 // return STRING_COMPARISONS_NOT_EQUAL; 63 // case OKBQueryService.StringComparison.NotLike: 64 // return STRING_COMPARISONS_NOT_LIKE; 65 // default: 66 // return STRING_COMPARISONS_EQUAL; //TODO 67 // } 68 //} 69 70 62 71 63 72 … … 85 94 } 86 95 } 96 97 public static OKBQueryService.EqualityComparison GetEqualityComparisonForValue(string comparisonValue) 98 { 99 int v = Int32.Parse(comparisonValue); 100 101 switch (v) 102 { 103 case (int)OKBQueryService.EqualityComparison.Equal: 104 return OKBQueryService.EqualityComparison.Equal; 105 case (int)OKBQueryService.EqualityComparison.NotEqual: 106 return OKBQueryService.EqualityComparison.NotEqual; 107 default: 108 return OKBQueryService.EqualityComparison.Equal; //TODO 109 } 110 } 111 112 public static OKBQueryService.OrdinalComparison GetOrdinalComparisonForValue(string comparisonValue) 113 { 114 int v = Int32.Parse(comparisonValue); 115 116 117 118 switch (v) 119 { 120 case (int)OKBQueryService.OrdinalComparison.Equal: 121 return OKBQueryService.OrdinalComparison.Equal; 122 case (int)OKBQueryService.OrdinalComparison.Greater: 123 return OKBQueryService.OrdinalComparison.Greater; 124 case (int)OKBQueryService.OrdinalComparison.GreaterOrEqual: 125 return OKBQueryService.OrdinalComparison.GreaterOrEqual; 126 case (int)OKBQueryService.OrdinalComparison.Less: 127 return OKBQueryService.OrdinalComparison.Less; 128 case (int)OKBQueryService.OrdinalComparison.NotEqual: 129 return OKBQueryService.OrdinalComparison.NotEqual; 130 case (int)OKBQueryService.OrdinalComparison.LessOrEqual: 131 return OKBQueryService.OrdinalComparison.LessOrEqual; 132 default: 133 return OKBQueryService.OrdinalComparison.Equal; //TODO 134 } 135 136 137 } 87 138 } 88 139 } -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/ViewModels/FilterModel.cs
r6191 r6245 56 56 57 57 58 public static List<ComparisonItem> BoolComparisons 59 { 60 get { return ComparisonsHelper.boolComparisons; } 61 } 62 58 63 public static List<ComparisonItem> OrdinalComparisons 59 64 { … … 67 72 68 73 69 //"<"; 70 //else if (Content.Comparison == OrdinalComparison.LessOrEqual) 71 // comparisonComboBox.SelectedItem = "<="; 72 //else if (Content.Comparison == OrdinalComparison.Equal) 73 // comparisonComboBox.SelectedItem = "="; 74 //else if (Content.Comparison == OrdinalComparison.GreaterOrEqual) 75 // comparisonComboBox.SelectedItem = ">="; 76 //else if (Content.Comparison == OrdinalComparison.Greater) 77 // comparisonComboBox.SelectedItem = ">"; 78 //else if (Content.Comparison == OrdinalComparison.NotEqual) 79 // comparisonComboBox.SelectedItem = "<>" 80 81 82 83 74 84 75 85 76 /// <summary> … … 205 196 { 206 197 if ("StringComparisonFilter".Equals(f.GetType().Name)) 207 { 208 209 ((StringComparisonFilter)f).Value = kvp.Value; 210 211 if (kvp.Key.Equals(FilterModel.ValueTextbox)) 212 { 213 ((StringComparisonFilter)f).Value = kvp.Value; // +"111"; 214 215 //((StringComparisonFilter)f).Value = ((StringComparisonFilter)f).Value; 216 // ((StringComparisonFilter)f).Comparison = ((StringComparisonFilter)f).Comparison; 217 218 219 } 220 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 221 { 222 // ((StringComparisonFilter)f).Value = ((StringComparisonFilter)f).Value; 223 ((StringComparisonFilter)f).Comparison = ComparisonsHelper.GetStringComparisonForValue(kvp.Value); 224 225 } 226 // To this for alle keys 227 228 } 198 { 199 if (kvp.Key.Equals(FilterModel.ValueTextbox)) 200 { 201 ((StringComparisonFilter)f).Value = kvp.Value; 202 } 203 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 204 { 205 ((StringComparisonFilter)f).Comparison = ComparisonsHelper.GetStringComparisonForValue(kvp.Value); 206 } 207 } 208 else if ("NameStringComparisonFilter".Equals(f.GetType().Name)) 209 { 210 if (kvp.Key.Equals(FilterModel.ValueTextbox)) 211 { 212 ((NameStringComparisonFilter)f).Value = kvp.Value; 213 } 214 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 215 { 216 ((NameStringComparisonFilter)f).Comparison = ComparisonsHelper.GetStringComparisonForValue(kvp.Value); 217 } 218 } 219 else if ("StringComparisonAvailableValuesFilter".Equals(f.GetType().Name)) 220 { 221 if (kvp.Key.Equals(FilterModel.ValueTextbox)) 222 { 223 ((StringComparisonAvailableValuesFilter)f).Value = kvp.Value; 224 } 225 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 226 { 227 ((StringComparisonAvailableValuesFilter)f).Comparison = ComparisonsHelper.GetStringComparisonForValue(kvp.Value); 228 } 229 } 230 else if ("NameStringComparisonAvailableValuesFilter".Equals(f.GetType().Name)) 231 { 232 if (kvp.Key.Equals(FilterModel.ValueTextbox)) 233 { 234 ((NameStringComparisonAvailableValuesFilter)f).Value = kvp.Value; 235 } 236 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 237 { 238 ((NameStringComparisonAvailableValuesFilter)f).Comparison = ComparisonsHelper.GetStringComparisonForValue(kvp.Value); 239 } 240 } 241 else if ("NameEqualityComparisonByteArrayFilter".Equals(f.GetType().Name)) 242 { 243 //TODO not supported 244 } 245 else if ("NameEqualityComparisonBoolFilter".Equals(f.GetType().Name)) 246 { 247 if (kvp.Key.Equals(FilterModel.ValueDropDownList)) 248 { 249 ((NameEqualityComparisonBoolFilter)f).Value = Boolean.Parse( kvp.Value); 250 } 251 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 252 { 253 ((NameEqualityComparisonBoolFilter)f).Comparison = ComparisonsHelper.GetEqualityComparisonForValue(kvp.Value); 254 } 255 } 256 else if ("NameOrdinalComparisonIntFilter".Equals(f.GetType().Name)) 257 { 258 if (kvp.Key.Equals(FilterModel.ValueTextbox)) 259 { 260 try 261 { 262 ((NameOrdinalComparisonIntFilter)f).Value = Int32.Parse(kvp.Value); 263 } 264 catch (Exception) 265 { 266 //TOOD Fehler ausgeben 267 } 268 } 269 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 270 { 271 ((NameOrdinalComparisonIntFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value); 272 } 273 } 274 else if ("NameOrdinalComparisonLongFilter".Equals(f.GetType().Name)) 275 { 276 if (kvp.Key.Equals(FilterModel.ValueTextbox)) 277 { 278 try 279 { 280 ((NameOrdinalComparisonLongFilter)f).Value = Int64.Parse(kvp.Value); 281 } 282 catch (Exception) 283 { 284 //TOOD Fehler ausgeben 285 } 286 } 287 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 288 { 289 ((NameOrdinalComparisonLongFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value); 290 } 291 } 292 293 else if ("NameOrdinalComparisonFloatFilter".Equals(f.GetType().Name)) 294 { 295 if (kvp.Key.Equals(FilterModel.ValueTextbox)) 296 { 297 try 298 { 299 ((NameOrdinalComparisonFloatFilter)f).Value = float.Parse(kvp.Value); 300 } 301 catch (Exception) 302 { 303 //TOOD Fehler ausgeben 304 } 305 } 306 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 307 { 308 ((NameOrdinalComparisonFloatFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value); 309 } 310 } 311 else if ("NameOrdinalComparisonDoubleFilter".Equals(f.GetType().Name)) 312 { 313 if (kvp.Key.Equals(FilterModel.ValueTextbox)) 314 { 315 try 316 { 317 ((NameOrdinalComparisonDoubleFilter)f).Value = Double.Parse(kvp.Value); 318 } 319 catch (Exception) 320 { 321 //TOOD Fehler ausgeben 322 } 323 } 324 else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList)) 325 { 326 ((NameOrdinalComparisonDoubleFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value); 327 } 328 } 329 330 229 331 else 230 332 { … … 234 336 235 337 } 236 StringComparisonFilter scf = (StringComparisonFilter)f; 237 //throw new Exception("Huhu ich bin doof"); 338 238 339 239 340 } -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Filter/Filters.ascx
r6191 r6245 20 20 21 21 <%: Html.Hidden(hiddenName,currentFilter.Id.ToString()) %> 22 <%: Html.DropDownList( comboboxName, new SelectList(((FilterModel)Model).AvailableFilterForCombobox, "FilterTypeName", "Label"))%>22 <%: Html.DropDownList( comboboxName, new SelectList(((FilterModel)Model).AvailableFilterForCombobox, "FilterTypeName", "Label"))%> 23 23 <input type="submit" value="+" /> 24 24 </p> … … 49 49 <% NameStringComparisonFilter filter = ((NameStringComparisonFilter)f); %> 50 50 <%: Html.Label(filter.Label)%> 51 <%: Html. Label("=")%>51 <%: Html.DropDownList(f.Id + "." + FilterModel.ComparisonDropDownList, new SelectList(FilterModel.StringComparisons, "Value", "Text",(int)filter.Comparison))%> 52 52 <%: Html.TextBox(f.Id + "." + FilterModel.ValueTextbox, filter.Value)%> 53 53 <% } … … 56 56 <% StringComparisonAvailableValuesFilter filter = ((StringComparisonAvailableValuesFilter)f); %> 57 57 <%: Html.Label(filter.Label)%> 58 <%: Html. Label("=")%>58 <%: Html.DropDownList(f.Id + "." + FilterModel.ComparisonDropDownList, new SelectList(FilterModel.StringComparisons, "Value", "Text",(int)filter.Comparison))%> 59 59 <%: Html.DropDownList(f.Id + "." + FilterModel.ValueTextbox, new SelectList(filter.AvailableValues, filter.Value))%> 60 60 <% } … … 63 63 <% NameEqualityComparisonByteArrayFilter filter = ((NameEqualityComparisonByteArrayFilter)f); %> 64 64 <%: Html.Label(filter.Label)%> 65 <%: Html.Label("teby")%>65 <%: Html.Label("not supported")%> 66 66 <% } 67 67 else if ("NameEqualityComparisonBoolFilter".Equals(f.GetType().Name)) 68 68 { %> 69 <% NameEqualityComparisonBoolFilter filter = ((NameEqualityComparisonBoolFilter)f); 70 %> 69 <% NameEqualityComparisonBoolFilter filter = ((NameEqualityComparisonBoolFilter)f); %> 71 70 <%: Html.Label(filter.Label)%> 72 <%: Html. Label("is") %>71 <%: Html.DropDownList(f.Id + "." + FilterModel.ComparisonDropDownList, new SelectList(FilterModel.BoolComparisons, "Value", "Text",(int)filter.Comparison))%> 73 72 <%: Html.DropDownList(f.Id + "." + FilterModel.ValueDropDownList, new SelectList(((FilterModel)Model).BoolStates, filter.Value))%> 74 73 <% } … … 77 76 <% NameOrdinalComparisonIntFilter filter = ((NameOrdinalComparisonIntFilter)f); %> 78 77 <%: Html.Label(filter.Label)%> 79 <%: Html.DropDownList(f.Id + "." + FilterModel. ValueDropDownList, new SelectList(FilterModel.OrdinalComparisons,"Value","Text",filter.Comparison))%>78 <%: Html.DropDownList(f.Id + "." + FilterModel.ComparisonDropDownList, new SelectList(FilterModel.OrdinalComparisons, "Value", "Text", (int)filter.Comparison))%> 80 79 <%: Html.TextBox(f.Id + "." + FilterModel.ValueTextbox, filter.Value)%> 81 80 <% } … … 84 83 <% NameStringComparisonAvailableValuesFilter filter = ((NameStringComparisonAvailableValuesFilter)f); %> 85 84 <%: Html.Label(filter.Label)%> 86 <%: Html. Label("=")%>85 <%: Html.DropDownList(f.Id + "." + FilterModel.ComparisonDropDownList, new SelectList(FilterModel.StringComparisons, "Value", "Text",(int)filter.Comparison))%> 87 86 <%: Html.DropDownList(f.Id + "." + FilterModel.ValueDropDownList, new SelectList(filter.AvailableValues, filter.Value))%> 88 87 <% } … … 91 90 <% NameOrdinalComparisonDoubleFilter filter = ((NameOrdinalComparisonDoubleFilter)f); %> 92 91 <%: Html.Label(filter.Label)%> 93 <%: Html. Label("<")%>92 <%: Html.DropDownList(f.Id + "." + FilterModel.ComparisonDropDownList, new SelectList(FilterModel.OrdinalComparisons, "Value", "Text", (int)filter.Comparison))%> 94 93 <%: Html.TextBox(f.Id + "." + FilterModel.ValueTextbox, filter.Value)%> 95 94 <% } … … 98 97 <% NameOrdinalComparisonFloatFilter filter = ((NameOrdinalComparisonFloatFilter)f); %> 99 98 <%: Html.Label(filter.Label)%> 100 <%: Html. Label("<")%>99 <%: Html.DropDownList(f.Id + "." + FilterModel.ComparisonDropDownList, new SelectList(FilterModel.OrdinalComparisons, "Value", "Text", (int)filter.Comparison))%> 101 100 <%: Html.TextBox(f.Id + "." + FilterModel.ValueTextbox, filter.Value)%> 102 101 <% } 103 else if ("NameOrdinalComparison FloatFilter".Equals(f.GetType().Name))102 else if ("NameOrdinalComparisonLongFilter".Equals(f.GetType().Name)) 104 103 { %> 105 104 <% NameOrdinalComparisonLongFilter filter = ((NameOrdinalComparisonLongFilter)f); %> 106 105 <%: Html.Label(filter.Label)%> 107 <%: Html. Label("<")%>106 <%: Html.DropDownList(f.Id + "." + FilterModel.ComparisonDropDownList, new SelectList(FilterModel.OrdinalComparisons, "Value", "Text", (int)filter.Comparison))%> 108 107 <%: Html.TextBox(f.Id + "." + FilterModel.ValueTextbox, filter.Value)%> 109 108 <% }
Note: See TracChangeset
for help on using the changeset viewer.