/// <summary> /// Binds the form. /// </summary> private void BindForm() { if (_segment != null) { if (_segment.Segment.Count > 0) { SegmentDto.SegmentRow row = _segment.Segment[0]; SegmentName.Text = string.IsNullOrEmpty(SegmentName.Text) ? row.Name : SegmentName.Text; DisplayName.Text = string.IsNullOrEmpty(DisplayName.Text) ? row.DisplayName : DisplayName.Text; Description.Text = string.IsNullOrEmpty(Description.Text) ? row.Description : Description.Text; int exprId = 0; exprId = FindDesignExpressionId(_segment); BindExpressionEditor(String.Format("customer;{0}", exprId)); } else { BindExpressionEditor(String.Format("customer;0")); } MemberList.DataSource = _segment.SegmentMember; MemberList.DataBind(); /* * ExpressionList.DataSource = _segment.SegmentCondition; * ExpressionList.DataBind(); * */ } else { BindExpressionEditor(String.Format("customer;0")); } }
/// <summary> /// Loads the fresh. /// </summary> /// <returns></returns> private SegmentDto LoadFresh() { SegmentDto segment = null; if (SegmentId == 0) { // Create an empty segment segment = new SegmentDto(); SegmentDto.SegmentRow row = segment.Segment.NewSegmentRow(); row.ApplicationId = MarketingConfiguration.Instance.ApplicationId; row.Name = ""; row.DisplayName = ""; row.Description = ""; if (row.RowState == DataRowState.Detached) { segment.Segment.Rows.Add(row); } } else { segment = SegmentManager.GetSegmentDto(SegmentId); } // persist in session Session[_SegmentDtoEditSessionKey] = segment; return(segment); }
/// <summary> /// Processes the delete command. /// </summary> /// <param name="items">The items.</param> void ProcessDeleteCommand(string[] items) { for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { string id = keys[0]; List <int> expressionList = new List <int>(); SegmentDto dto = SegmentManager.GetSegmentDto(Int32.Parse(id)); if (dto.Segment.Count > 0) { SegmentDto.SegmentRow segmentRow = dto.Segment[0]; foreach (SegmentDto.SegmentConditionRow condition in segmentRow.GetSegmentConditionRows()) { expressionList.Add(condition.ExpressionId); } dto.Segment[0].Delete(); SegmentManager.SaveSegment(dto); } // Delete corresponding expressions foreach (int expressionId in expressionList) { ExpressionDto expressionDto = ExpressionManager.GetExpressionDto(expressionId); if (expressionDto != null && expressionDto.Expression.Count > 0) { expressionDto.Expression[0].Delete(); ExpressionManager.SaveExpression(expressionDto); } } } } }
/// <summary> /// Saves the changes. /// </summary> public void SaveChanges() { //Serialize FilterExpression in segment table if (_segment != null && _segment.Segment.Count > 0) { SegmentDto.SegmentRow row = _segment.Segment[0]; row.ExpressionFilter = SerializeFilterExpressions(ExpressionFilters); } }
private List <FilterExpressionNodeCollection> LoadSerializedFilters() { List <FilterExpressionNodeCollection> retVal = null; //try first deserialize if (_segment != null && _segment.Segment.Count != 0) { SegmentDto.SegmentRow row = _segment.Segment[0]; if (!row.IsExpressionFilterNull()) { retVal = DeseralizeFilterExpressions(row.ExpressionFilter); } } if (retVal == null) { retVal = new List <FilterExpressionNodeCollection>(); } return(retVal); }
/// <summary> /// Saves the changes. /// </summary> /// <param name="context">The context.</param> public void SaveChanges(IDictionary context) { int expressionId = 0; SegmentDto dto = (SegmentDto)context[_SegmentDtoString]; SegmentDto.SegmentRow row = null; if (dto.Segment.Count > 0) { row = dto.Segment[0]; expressionId = FindDesignExpressionId(dto); } else { row = dto.Segment.NewSegmentRow(); row.ApplicationId = MarketingConfiguration.Instance.ApplicationId; } row.Name = SegmentName.Text; row.DisplayName = DisplayName.Text; row.Description = Description.Text; //Tell RulesEditorCtrl save changes RulesEditorCtrl.SaveChanges(); if (row.RowState == DataRowState.Detached) { dto.Segment.Rows.Add(row); } /* * // design-ui denotes that this expression was created using design ui * if(ExprFilter.Visible) * ExprFilter.Provider.SaveFilters(_RulesPrefix, String.Format("{0}:{1}", row.SegmentId, expressionId), ExprFilter.NodeCollection[0].ChildNodes); * */ }