private void StopObservingColumnsModel() { if (cachedColumnsModel != null) { cachedColumnsModel.Columns.CollectionChanged -= HandleColumnsChanged; cachedColumnsModel = null; } }
private void StartObservingColumnsModel(ColumnsModel columnsModel) { if (columnsModel != null) { cachedColumnsModel = columnsModel; cachedColumnsModel.Columns.CollectionChanged += HandleColumnsChanged; } }
public ActionResult GetColumns(int projectId) { ColumnsModel model = new ColumnsModel(); List <ScreenField> fields = GetRoadmapFields(projectId); IssuesFilter filter = ItemFilterManager.TransformFilter(IssuesFilter.CreateProjectFilter(CurrentUser.Entity.Id, projectId)); SetCurrentProjectFromFilter(filter); model.Columns = GridManager.GetAvailableColumns(filter.GetProjects(), IssueFilterHelper.AggregateTypes(filter, ProjectManager, MetaManager), fields); return(JsonSuccess(RenderPartialViewToString(this, "~/Views/Items/ColumnSelector.cshtml", model))); }
private List <ColumnsModel> Lay_danh_sach_cot_table_khach_hang() { List <ColumnsModel> op_lst_col_kh = new List <ColumnsModel>(); BKI_CRMEntities v_model = new BKI_CRMEntities(); var v_guid = new Guid("d63820f1-b56a-4553-a488-d3b79b27f4f1"); var v_lst_col_kh = v_model.CM_DM_TU_DIEN.Where(x => x.ID_LOAI_TU_DIEN == v_guid).ToList(); foreach (var item in v_lst_col_kh) { ColumnsModel v_col_kh = new ColumnsModel(); v_col_kh = item.CopyAs <ColumnsModel>(); op_lst_col_kh.Add(v_col_kh); } return(op_lst_col_kh); }
public ActionResult SetColumns(ColumnsModel columnsModel, int projectId, int versionId) { List <ListItem> selected = columnsModel.Columns.FindAll(c => c.IsSelected); List <UserIssuesView> currentView = GridManager.GetUserViewColumns(ProjectTemplatePageType.Custom); int sequence = 0; // Remove all properties that are not in the new view. currentView.RemoveAll(v => !v.IsCustomField && selected.Find(s => s.ItemId == ((int)v.Attribute).ToString()) == null); currentView.RemoveAll(v => v.IsCustomField && selected.Find(s => s.ItemId == v.CustomFieldId) == null); var extra = selected.FindAll(s => currentView.Find(v => !v.IsCustomField && s.ItemId == ((int)v.Attribute).ToString() || v.IsCustomField && s.ItemId == v.CustomFieldId) == null); foreach (var selectedCol in extra) { UserIssuesView column = new UserIssuesView(); column.UserId = CurrentUser.Entity.Id; column.ProjectId = projectId; column.Sequence = 999; column.ViewType = ProjectTemplatePageType.Custom; if (selectedCol.ItemId.StartsWith("cf_", StringComparison.InvariantCulture)) { column.CustomFieldId = selectedCol.ItemId; } else { column.Attribute = (ItemAttributeVisibility)selectedCol.ItemId.ToInt(); } currentView.Add(column); } currentView.ForEach(v => { v.Sequence = sequence++; v.UserId = CurrentUser.Entity.Id; }); HttpSessionManager.Set(currentView, Constants.ChangelogSessionView); return(JsonSuccess(new { view = currentView })); }
private void UpdateColumnSet() { if (!IsLoaded || ApplicationModel.Database.Value == null) { return; } var columnsModel = PerDatabaseState.DocumentViewState.GetDocumentState(context); if (columnsModel != null) { Columns = columnsModel; } else { Columns = new ColumnsModel(); PerDatabaseState.DocumentViewState.SetDocumentState(context, Columns); TryLoadDefaultColumnSet(); } }
private async Task ExecuteReport() { QueryErrorMessage.Value = ""; IsErrorVisible.Value = false; if (string.IsNullOrEmpty(GroupByField.Value)) { ApplicationModel.Current.Notifications.Add(new Notification("You must select a field to group by")); return; } if (ValueCalculations.Count == 0) { ApplicationModel.Current.Notifications.Add(new Notification("You must add at least one Value")); return; } var facets = new List <AggregationQuery>(); foreach (var value in ValueCalculations) { var facetForField = facets.FirstOrDefault(f => f.AggregationField == value.Field); if (facetForField != null) { facetForField.Aggregation |= value.SummaryMode; } else { facets.Add(new AggregationQuery { Name = GroupByField.Value, DisplayName = GroupByField.Value + "-" + value.Field, AggregationField = value.Field, Aggregation = value.SummaryMode }); } } ResultColumns = null; Results.Clear(); var cancelationTokenSource = new CancellationTokenSource(); var progressWindow = new ProgressWindow() { Title = "Preparing Report", IsIndeterminate = false, CanCancel = true }; progressWindow.Closed += delegate { cancelationTokenSource.Cancel(); }; progressWindow.Show(); var queryStartTime = DateTime.UtcNow.Ticks; try { var results = new List <KeyValuePair <string, FacetResult> >(); var hasMoreResults = true; var fetchedResults = 0; while (hasMoreResults) { var queryFacetsTask = DatabaseCommands.GetFacetsAsync(IndexName, new IndexQuery() { Query = FilterDoc.Text }, AggregationQuery.GetFacets(facets), fetchedResults, 256); await TaskEx.WhenAny( queryFacetsTask, TaskEx.Delay(int.MaxValue, cancelationTokenSource.Token)); if (cancelationTokenSource.IsCancellationRequested) { return; } var facetResults = await queryFacetsTask; results.AddRange(facetResults.Results); fetchedResults += facetResults.Results.Select(r => r.Value.Values.Count).Max(); var remainingResults = facetResults.Results.Select(r => r.Value.RemainingTermsCount).Max(); var totalResults = fetchedResults + remainingResults; progressWindow.Progress = (int)((fetchedResults / (double)totalResults) * 100); hasMoreResults = remainingResults > 0; } var rowsByKey = new Dictionary <string, ReportRow>(); var rows = new List <ReportRow>(); foreach (var facetResult in results) { var calculatedField = facetResult.Key.Split('-')[1]; foreach (var facetValue in facetResult.Value.Values) { ReportRow result; if (!rowsByKey.TryGetValue(facetValue.Range, out result)) { result = new ReportRow { Key = facetValue.Range }; rowsByKey.Add(result.Key, result); rows.Add(result); } foreach ( var valueCalculation in ValueCalculations.Where(v => v.Field == calculatedField)) { var value = facetValue.GetAggregation(valueCalculation.SummaryMode); if (value.HasValue) { result.Values.Add(valueCalculation.Header, facetValue.GetAggregation(valueCalculation.SummaryMode) ?? 0); } } } } var columns = new ColumnsModel(); columns.Columns.Add(new ColumnDefinition() { Header = "Key", Binding = "Key" }); columns.Columns.AddRange( ValueCalculations.Select( k => new ColumnDefinition() { Header = k.Header, Binding = "Values[" + k.Header + "]" })); Results.AddRange(rows); ResultColumns = columns; var queryEndTime = DateTime.UtcNow.Ticks; ExecutionElapsedTime.Value = new TimeSpan(queryEndTime - queryStartTime); } catch (AggregateException ex) { var badRequest = ex.ExtractSingleInnerException() as BadRequestException; if (badRequest != null) { QueryErrorMessage.Value = badRequest.Message; IsErrorVisible.Value = true; } else { throw; } } catch (TaskCanceledException) { } finally { // there's a bug in silverlight where if a ChildWindow gets closed too soon after it's opened, it leaves the UI // disabled; so delay closing the window by a few milliseconds TaskEx.Delay(TimeSpan.FromMilliseconds(350)) .ContinueOnSuccessInTheUIThread(progressWindow.Close); } }
public void SetDocumentState(string context, ColumnsModel columns) { documentViewState[context] = columns; }
/// <summary> /// 验证是否为空 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="columnsList"></param> /// <param name="model"></param> /// <returns></returns> public static ValidateResModel ValidateNullOrEmpty <T>(List <ColumnsModel> columnsList, T model) { ValidateResModel res = new ValidateResModel() { IsValidate = true }; //默认验证通过 ColumnsModel columnsModel = null; PropertyInfo property = null; //属性对象 Object property_value = null; //属性值 string str = ""; for (int j = 0; j < columnsList.Count; j++) { columnsModel = columnsList[j]; property = typeof(T).GetProperty(columnsModel.PropertyName.Trim()); if (property == null) { throw new Exception("列名'" + columnsModel.PropertyName + "'不存在类中"); } property_value = property.GetValue(model, null); if (property.PropertyType == typeof(DateTime) || property.PropertyType == typeof(DateTime?)) { try { Convert.ToDateTime(property_value); } catch { res.IsValidate = false; res.ValidateMsg = columnsModel.ChinaName + "时间格式不正确"; break; } } else if (property.PropertyType == typeof(string)) { str = property_value == null ? "" : Convert.ToString(property_value); if (!columnsModel.IsNullable) {//必输 if (string.IsNullOrEmpty(str.Trim())) { res.IsValidate = false; res.ValidateMsg = columnsModel.ChinaName + "不能为空"; break; } } #region 验证日期类型的字符串格式(因为json这边接收的日期类型都是字符串) if (columnsModel.DataType == typeof(DateTime) && !string.IsNullOrEmpty(str)) {//如果是日期类型,并且传入的值不为空,则需要验证日期格式是否正确 try { Convert.ToDateTime(property_value); } catch { res.IsValidate = false; res.ValidateMsg = columnsModel.ChinaName + "时间格式不正确"; break; } } #endregion #region 验证格林威治日期类型的字符串格式(因为json这边接收的日期类型都是字符串) if (columnsModel.DataType == typeof(GreenwichTimeStamp) && !string.IsNullOrEmpty(str)) {//如果是日期类型,并且传入的值不为空,则需要验证日期格式是否正确 try { DateTime?dt = WIPCommon.ForamtGreenwichTimeStampToDateTime(str); if (dt == null) { res.IsValidate = false; res.ValidateMsg = columnsModel.ChinaName + "格林威治时间格式不正确"; } } catch { res.IsValidate = false; res.ValidateMsg = columnsModel.ChinaName + "格林威治时间格式不正确"; break; } } #endregion } else if (property.PropertyType == typeof(int)) { try { int timestamp = Convert.ToInt32(property_value); if (timestamp == 0) { res.IsValidate = false; res.ValidateMsg = columnsModel.ChinaName + "不能为0"; break; } } catch { res.IsValidate = false; res.ValidateMsg = columnsModel.ChinaName + "int格式不正确"; break; } } else if (property.PropertyType == typeof(long)) { if (columnsModel.DataType == typeof(UnixTimeStamp)) {//验证long类型的unix时间戳 try { long timestamp = Convert.ToInt64(property_value); if (timestamp == 0) { res.IsValidate = false; res.ValidateMsg = columnsModel.ChinaName + "unix时间戳不能为0"; break; } } catch { res.IsValidate = false; res.ValidateMsg = columnsModel.ChinaName + "unix时间戳格式不正确"; break; } } } else if (property.PropertyType == typeof(decimal) || property.PropertyType == typeof(decimal?)) { } } return(res); }