/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (plInviteFriendSettings.Visible) { if (siteActivityRule != null) { var inviteFriendComponent = siteActivityRule.tbl_SiteActivityRuleLayout.FirstOrDefault(o => o.LayoutType == (int)LayoutType.InviteFriend); if (inviteFriendComponent != null && !string.IsNullOrEmpty(inviteFriendComponent.LayoutParams)) { var lp = LayoutParams.Deserialize(inviteFriendComponent.LayoutParams); if (!string.IsNullOrEmpty(lp.GetValue("SiteActionTemplateID"))) { ucPopupSiteActionTemplate.UpdateUI(DataManager.SiteActionTemplate.SelectById(Guid.Parse(lp.GetValue("SiteActionTemplateID")))); } } } else { var siteActionTemplate = DataManager.SiteActionTemplate.SelectById(ucPopupSiteActionTemplate.SiteActionTemplateId); ucPopupSiteActionTemplate.UpdateUI(siteActionTemplate); } } }
/// <summary> /// Binds the data. /// </summary> public override void BindData() { base.BindData(); if (EditObjectId.HasValue) { var siteActivityRule = DataManager.SiteActivityRules.SelectById(EditObjectId.Value); ProceedSiteActivityRule(siteActivityRule); txtFormWidth.Value = siteActivityRule.FormWidth; ucCssEditorButton.Css = siteActivityRule.CSSButton; var siteActivityRuleLayouts = siteActivityRule.tbl_SiteActivityRuleLayout.Where(o => !string.IsNullOrEmpty(o.LayoutParams)).OrderBy(o => o.Order); foreach (var activityRuleLayout in siteActivityRuleLayouts) { var layoutParams = LayoutParams.Deserialize(activityRuleLayout.LayoutParams); if (!string.IsNullOrEmpty(layoutParams.GetValue("ShowInMaster")) && int.Parse(layoutParams.GetValue("ShowInMaster")) > 1) { if (!string.IsNullOrEmpty(activityRuleLayout.CSSStyle)) { ucCssEditorInstruction.Css = activityRuleLayout.CSSStyle; break; } } } siteActivityRuleLayouts = siteActivityRule.tbl_SiteActivityRuleLayout.Where(o => string.IsNullOrEmpty(o.LayoutParams) && !string.IsNullOrEmpty(o.CSSStyle)).OrderBy(o => o.Order); if (siteActivityRuleLayouts.Any()) { var tblSiteActivityRuleLayout = siteActivityRuleLayouts.FirstOrDefault(); if (tblSiteActivityRuleLayout != null) { ucCssEditorColumns.Css = tblSiteActivityRuleLayout.CSSStyle; } } DecodeCss(siteActivityRule.CSSForm); } else { ProceedSiteActivityRule(DataManager.SiteActivityRules.SelectById(CurrentForm)); } ucCssEditorButton.BindData(); ucCssEditorColumns.BindData(); ucCssEditorInstruction.BindData(); }
/// <summary> /// Binds the data. /// </summary> public override void BindData() { base.BindData(); if (IsEditMode && EditObjectId.HasValue) { siteActivityRule = DataManager.SiteActivityRules.SelectById(EditObjectId.Value); if (siteActivityRule != null) { txtUrl.Text = siteActivityRule.RepostURL; if (siteActivityRule.tbl_SiteActivityRuleLayout.Any(o => o.LayoutType == (int)LayoutType.InviteFriend)) { plInviteFriendSettings.Visible = true; var inviteFriendComponent = siteActivityRule.tbl_SiteActivityRuleLayout.FirstOrDefault(o => o.LayoutType == (int)LayoutType.InviteFriend); if (inviteFriendComponent != null && !string.IsNullOrEmpty(inviteFriendComponent.LayoutParams)) { var lp = LayoutParams.Deserialize(inviteFriendComponent.LayoutParams); if (!string.IsNullOrEmpty(lp.GetValue("WorkflowTemplateID"))) { var workflowTemplate = DataManager.WorkflowTemplate.SelectById(CurrentUser.Instance.SiteID, Guid.Parse(lp.GetValue("WorkflowTemplateID"))); if (workflowTemplate != null) { dcbWorkflowTemplate.SelectedIdNullable = workflowTemplate.ID; dcbWorkflowTemplate.SelectedText = workflowTemplate.Name; } ucPopupSiteActionTemplate.UpdateUI(DataManager.SiteActionTemplate.SelectById(Guid.Parse(lp.GetValue("SiteActionTemplateID")))); ucPopupSiteActionTemplate.SiteActionTemplateId = Guid.Parse(lp.GetValue("SiteActionTemplateID")); } } } } } else { var templateSiteActivityRule = DataManager.SiteActivityRules.SelectById(CurrentForm); if (templateSiteActivityRule.tbl_SiteActivityRuleLayout.Any(o => o.LayoutType == (int)LayoutType.InviteFriend)) { plInviteFriendSettings.Visible = true; } } if (plInviteFriendSettings.Visible) { ucPopupSiteActionTemplate.ForceNotPostbackPageLoad(); } }
/// <summary> /// Determines whether the specified parent id is container. /// </summary> /// <param name="parentId">The parent id.</param> /// <returns> /// <c>true</c> if the specified parent id is container; otherwise, <c>false</c>. /// </returns> private bool IsContainer(Guid?parentId) { var siteActivityRuleLayout = DataManager.SiteActivityRuleLayout.SelectById(parentId.Value); if (string.IsNullOrEmpty(siteActivityRuleLayout.LayoutParams)) { return(false); } var lp = LayoutParams.Deserialize(siteActivityRuleLayout.LayoutParams); if (!string.IsNullOrEmpty(lp.GetValue("IsUsedForAdditionalDetails")) && bool.Parse(lp.GetValue("IsUsedForAdditionalDetails"))) { return(true); } return(false); }
protected void BindFeedBackAttributes(string lp) { rblStep.Items.Clear(); foreach (var step in EnumHelper.EnumToList <FormFeedBackSteps>()) { rblStep.Items.Add(new ListItem(EnumHelper.GetEnumDescription(step), ((int)step).ToString())); } rblKnowledgeBase.Items.Clear(); foreach (var knowledgeBase in EnumHelper.EnumToList <FormFeedBackKnowledgeBase>()) { rblKnowledgeBase.Items.Add(new ListItem(EnumHelper.GetEnumDescription(knowledgeBase), ((int)knowledgeBase).ToString())); } var publicationTypes = DataManager.PublicationType.SelectByPublicationKindID(CurrentUser.Instance.SiteID, (int)PublicationKind.Discussion); chxPublicationType.DataSource = publicationTypes; chxPublicationType.DataTextField = "Title"; chxPublicationType.DataValueField = "ID"; chxPublicationType.DataBind(); if (!string.IsNullOrEmpty(lp)) { var layoutParams = LayoutParams.Deserialize(lp); rblStep.SelectedIndex = rblStep.Items.IndexOf(rblStep.Items.FindByValue(layoutParams.GetValue("step"))); rblKnowledgeBase.SelectedIndex = rblKnowledgeBase.Items.IndexOf(rblKnowledgeBase.Items.FindByValue(layoutParams.GetValue("kb"))); var publicationTypeIds = layoutParams.GetValue("pt").Split(','); foreach (var publicationTypeId in publicationTypeIds) { if (!string.IsNullOrEmpty(publicationTypeId) && chxPublicationType.Items.FindByValue(publicationTypeId) != null) { chxPublicationType.Items.FindByValue(publicationTypeId).Selected = true; } } } else { rblStep.Items.FindByValue("1").Selected = true; rblKnowledgeBase.Items.FindByValue("1").Selected = true; } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request.QueryString["sarId"])) { return; } _publicationType.Clear(); var siteActivityRule = _dataManager.SiteActivityRules.SelectById(Guid.Parse(Request.QueryString["sarId"])); if (siteActivityRule != null) { var layout = siteActivityRule.tbl_SiteActivityRuleLayout.FirstOrDefault(o => (LayoutType)o.LayoutType == LayoutType.Feedback); if (layout == null || string.IsNullOrEmpty(layout.LayoutParams)) { return; } var layoutParams = LayoutParams.Deserialize(layout.LayoutParams); if (!string.IsNullOrEmpty(layoutParams.GetValue("pt"))) { var types = layoutParams.GetValue("pt").Split(','); foreach (var pType in types) { _publicationType.Add(Guid.Parse(pType)); } } if (!string.IsNullOrEmpty(layoutParams.GetValue("step"))) { _step = int.Parse(layoutParams.GetValue("step")); } if (!string.IsNullOrEmpty(layoutParams.GetValue("kb"))) { _knowledgeBase = int.Parse(layoutParams.GetValue("kb")); } if (!string.IsNullOrEmpty(siteActivityRule.CSSForm)) { plContainer.Attributes.Add("style", siteActivityRule.CSSForm); } if (!string.IsNullOrEmpty(siteActivityRule.CSSButton)) { lbtnSecondStepNext.Attributes.Add("style", siteActivityRule.CSSButton); lbtnThirdStepNext.Attributes.Add("style", siteActivityRule.CSSButton); ucLoggedAs.SetCSS(siteActivityRule.CSSButton); } } if (!string.IsNullOrEmpty(Request.QueryString["sId"])) { _siteId = Guid.Parse(Request.QueryString["sId"]); } if (!Page.IsPostBack) { var portalSettings = _dataManager.PortalSettings.SelectBySiteId(_siteId); if (portalSettings != null) { if (!string.IsNullOrEmpty(portalSettings.Domain)) { hlPortal.NavigateUrl = string.Format("http://{0}", portalSettings.Domain.Replace("http://", string.Empty)); } else { hlPortal.NavigateUrl = Settings.LabitecLeadForcePortalUrl + "/" + portalSettings.ID; } } } hfSiteId.Value = _siteId.ToString(); Page.Header.DataBind(); ucLoggedAs.SiteId = _siteId; if (!Page.IsPostBack) { BindData(); } }
/// <summary> /// Binds the data. /// </summary> public override void BindData() { base.BindData(); tbl_SiteActivityRules siteActivityRule = null; if (!IsEditMode) { siteActivityRule = DataManager.SiteActivityRules.SelectById(CurrentForm); } else if (EditObjectId.HasValue) { siteActivityRule = DataManager.SiteActivityRules.SelectById(EditObjectId.Value); txtFormTitleRequiredFieldValidator.ValidationGroup = "groupEdit"; } else { return; } if (siteActivityRule == null) { return; } var siteActivityRuleLayouts = siteActivityRule.tbl_SiteActivityRuleLayout.Where(o => !string.IsNullOrEmpty(o.LayoutParams)).OrderBy(o => o.Order); txtFormTitle.Text = siteActivityRule.Name; txtTextButton.Text = siteActivityRule.TextButton; foreach (var activityRuleLayout in siteActivityRuleLayouts) { var layoutParams = LayoutParams.Deserialize(activityRuleLayout.LayoutParams); if (!string.IsNullOrEmpty(layoutParams.GetValue("ShowInMaster"))) { var panel = new Panel() { CssClass = "row" }; var label = new HtmlGenericControl { TagName = "label", InnerText = string.Format("{0}:", activityRuleLayout.Name) }; panel.Controls.Add(label); switch ((ShowTextBlockInMaster)int.Parse(layoutParams.GetValue("ShowInMaster"))) { case ShowTextBlockInMaster.Text: var textBox = new TextBox() { ID = activityRuleLayout.ID.ToString(), CssClass = "area-text", TextMode = TextBoxMode.MultiLine, Height = new Unit(30, UnitType.Pixel), Width = new Unit(689, UnitType.Pixel) }; textBox.Text = activityRuleLayout.Description; panel.Controls.Add(textBox); break; case ShowTextBlockInMaster.HTML: panel.CssClass = "row-html-editor clearfix"; panel.Attributes.Add("style", "margin-bottom:10px"); var htmlEditor = new RadEditor() { ID = activityRuleLayout.ID.ToString(), EnableResize = false, ToolsFile = "~/RadEditor/Tools.xml", CssClass = "rad-editor", AutoResizeHeight = false, Width = new Unit(700, UnitType.Pixel), Height = new Unit(130, UnitType.Pixel), Skin = "Windows7", ContentAreaMode = EditorContentAreaMode.Iframe }; htmlEditor.Content = activityRuleLayout.Description; panel.Controls.Add(htmlEditor); break; } plTextBlocksContainer.Controls.Add(panel); } } }
protected void BuildLayout(Guid siteID, Guid contactID, tbl_SiteActivityRules siteActivityRule, List <SiteActivityRuleLayoutParams> siteActivityRuleLayouts, SiteActivityRuleLayoutParams parentLayout, List <ContactColumnValueMap> contactColumnValues, bool register) { var skin = ((Skin)siteActivityRule.Skin).ToString(); FormDecorator.Skin = skin; List <SiteActivityRuleLayoutParams> layouts; if (parentLayout == null) { layouts = siteActivityRuleLayouts.Where(a => a.ParentID == null).OrderBy(a => a.Order).ToList(); } else { layouts = siteActivityRuleLayouts.Where(a => a.ParentID == parentLayout.ID).OrderBy(a => a.Order).ToList(); } foreach (var layout in layouts) { var controlToInsert = new Control(); var container = new Panel(); var fieldWrapper = new Panel { CssClass = "field-wrapper" }; if (parentLayout == null) { controlToInsert = pnlFormContainer; } else { controlToInsert = pnlFormContainer.FindControl(string.Format("csf-{0}", layout.ParentID.ToString().Replace("-", "__"))); } switch ((LayoutType)layout.LayoutType) { case LayoutType.GroupFields: if ((OutputFormat)layout.OutputFormat == OutputFormat.Header) { var hdr = new Panel { CssClass = string.Format("hdr-{0}", layout.ID) }; var linkHdr = new LinkButton { Text = layout.Name, OnClientClick = string.Format("toggleForm('csf-{0}'); return false;", layout.ID), CssClass = "hdr" }; hdr.Controls.Add(linkHdr); controlToInsert.Controls.Add(hdr); } var pnl = new Panel { ID = string.Format("csf-{0}", layout.ID.ToString().Replace("-", "__")), CssClass = string.Format("csf-{0}", layout.ID) }; pnl.Attributes.Add("style", "width: 100%; display: table;" + layout.CSSStyle); controlToInsert.Controls.Add(pnl); break; case LayoutType.TextBlock: var textBlock = new Panel { CssClass = string.Format("csf-{0}", layout.ID), ClientIDMode = ClientIDMode.Static }; textBlock.Controls.Add(new Literal { Text = layout.Description }); if (!string.IsNullOrEmpty(layout.CSSStyle) && layout.CSSStyle.Trim() != string.Empty) { textBlock.Attributes.Add("style", layout.CSSStyle); } if (!string.IsNullOrEmpty(siteActivityRule.ErrorMessage) && !string.IsNullOrEmpty(layout.LayoutParams)) { var layoutParams = LayoutParams.Deserialize(layout.LayoutParams); if (layoutParams.GetBoolValue("IsUsedForErrorMessage")) { if (textBlock.Attributes["style"] != null) { textBlock.Attributes["style"] += ";display:none"; } else { textBlock.Attributes.Add("style", "display:none;"); } textBlock.Attributes["style"] += "padding: 5px 0;color:#b63306"; textBlock.ID = "LFErrorMessageTextBlock"; } } container.Controls.Add(textBlock); controlToInsert.Controls.Add(container); break; case LayoutType.Image: var binaryImage = new RadBinaryImage { CssClass = string.Format("csf-{0}", layout.ID), ClientIDMode = ClientIDMode.Static }; var fsp = new FileSystemProvider(); var filePath = fsp.GetRemoteLink(siteID, "SiteActivityRule", layout.ID.ToString() + ".png", FileType.Image); binaryImage.ImageUrl = filePath; if (!string.IsNullOrEmpty(layout.LayoutParams)) { var layoutParams = LayoutParams.Deserialize(layout.LayoutParams); if (!string.IsNullOrEmpty(layoutParams.GetValue("ImageWidth"))) { binaryImage.Width = new Unit(int.Parse(layoutParams.GetValue("ImageWidth")), UnitType.Pixel); } if (!string.IsNullOrEmpty(layoutParams.GetValue("ImageHeight"))) { binaryImage.Height = new Unit(int.Parse(layoutParams.GetValue("ImageHeight")), UnitType.Pixel); } if (!string.IsNullOrEmpty(layoutParams.GetValue("ImageAlign"))) { container.Attributes.CssStyle.Add("text-align", layoutParams.GetValue("ImageAlign")); } if (!string.IsNullOrEmpty(layoutParams.GetValue("ImageAlternativeText"))) { binaryImage.AlternateText = layoutParams.GetValue("ImageAlternativeText"); } } container.Controls.Add(binaryImage); controlToInsert.Controls.Add(container); break; case LayoutType.ProfileField: case LayoutType.FormField: if (register && layout.IsAdmin) { continue; } //var controlId = string.Format("LF{0}___{1}___", counter++, layout.SiteColumnID.HasValue ? ((Guid)layout.SiteColumnID).ToString() : layout.SysField); var controlId = string.Format("LF{0}___{1}___", counter++, layout.SiteColumnID.HasValue ? ((Guid)layout.SiteColumnID).ToString().Replace("-", "__") : layout.SysField); var field = contactData.GetFieldByValue(layout.SiteColumnID.HasValue ? ((Guid)layout.SiteColumnID).ToString() : layout.SysField, siteActivityRule.ID); var label = new Label { AssociatedControlID = controlId, Text = layout.SiteColumnID.HasValue ? layout.SiteColumnName : field.Name, CssClass = "label" }; var fieldClass = string.Empty; if (parentLayout != null) { if ((OutputFormatFields)parentLayout.OutputFormatFields == OutputFormatFields.Top || (OutputFormatFields)parentLayout.OutputFormatFields == OutputFormatFields.Left) { container.Controls.Add(label); } if ((OutputFormatFields)parentLayout.OutputFormatFields == OutputFormatFields.Top) { container.Controls.Add(new LiteralControl("<br />")); } fieldClass = GetFieldClass(parentLayout); if (!string.IsNullOrEmpty(fieldClass)) { container.CssClass = fieldClass; } } //var contactDataValues = contactData.GetContactData(contactID); //RadDatePicker datePicker = new RadDatePicker(); var dataValue = contactDataValues.FirstOrDefault(a => a.Key == field.Value); switch (field.ColumnType) { case ColumnType.String: var textBox = new RadTextBox { ID = controlId, Width = new Unit(98, UnitType.Percentage), Skin = skin }; if (!string.IsNullOrEmpty(dataValue.Key)) { textBox.Text = dataValue.Value; } else if (field.IsAdditional && !string.IsNullOrEmpty(layout.DefaultValue)) { textBox.Text = layout.DefaultValue; } if (!string.IsNullOrEmpty(layout.CSSStyle)) { textBox.Attributes.Add("style", ClearBackground(layout.CSSStyle)); } textBox.Attributes.Add("onfocus", "TextboxFocus(this);"); if ((OutputFormatFields)parentLayout.OutputFormatFields == OutputFormatFields.InElement) { textBox.EmptyMessage = layout.SiteColumnID.HasValue ? layout.SiteColumnName : field.Name; } fieldWrapper.Controls.Add(textBox); container.Controls.Add(fieldWrapper); break; case ColumnType.Text: var text = new RadTextBox { ID = controlId, Width = new Unit(98, UnitType.Percentage), TextMode = InputMode.MultiLine, Skin = skin }; if (!string.IsNullOrEmpty(dataValue.Key)) { text.Text = !string.IsNullOrEmpty(dataValue.Value) ? dataValue.Value.Replace("<br />", "\n") : null; } else if (field.IsAdditional && !string.IsNullOrEmpty(layout.DefaultValue)) { text.Text = !string.IsNullOrEmpty(layout.DefaultValue) ? layout.DefaultValue.Replace("<br />", "\n") : null; } if (!string.IsNullOrEmpty(layout.CSSStyle)) { text.Attributes.Add("style", ClearBackground(layout.CSSStyle)); } text.Attributes.Add("onfocus", "TextboxFocus(this);"); if ((OutputFormatFields)parentLayout.OutputFormatFields == OutputFormatFields.InElement) { text.EmptyMessage = layout.SiteColumnID.HasValue ? layout.SiteColumnName : field.Name; } fieldWrapper.Controls.Add(text); container.Controls.Add(fieldWrapper); break; case ColumnType.Number: var numericTextBox = new RadNumericTextBox { ID = controlId, Width = new Unit(98, UnitType.Percentage), AutoCompleteType = AutoCompleteType.Disabled, Type = NumericType.Number, Skin = skin.ToString() }; numericTextBox.NumberFormat.GroupSeparator = ""; numericTextBox.NumberFormat.DecimalDigits = 0; if (!string.IsNullOrEmpty(dataValue.Key)) { numericTextBox.Text = dataValue.Value; } else if (field.IsAdditional && !string.IsNullOrEmpty(layout.DefaultValue)) { numericTextBox.Text = layout.DefaultValue; } if (!string.IsNullOrEmpty(layout.CSSStyle)) { numericTextBox.Attributes.Add("style", ClearBackground(layout.CSSStyle)); } numericTextBox.Attributes.Add("onfocus", "TextboxFocus(this);"); if ((OutputFormatFields)parentLayout.OutputFormatFields == OutputFormatFields.InElement) { numericTextBox.EmptyMessage = layout.SiteColumnID.HasValue ? layout.SiteColumnName : field.Name; } fieldWrapper.Controls.Add(numericTextBox); container.Controls.Add(fieldWrapper); break; case ColumnType.Date: var datePicker = new RadDateTimePicker { ID = controlId, Width = new Unit(98, UnitType.Percentage), ShowPopupOnFocus = true, Skin = skin }; datePicker.TimePopupButton.Visible = false; datePicker.DateInput.DateFormat = "dd/MM/yyyy"; if (layout.ColumnTypeExpressionID.HasValue) { var columnTypesExpression = repository.ColumnTypesExpression_SelectById((Guid)layout.ColumnTypeExpressionID); datePicker.DateInput.DateFormat = columnTypesExpression.Expression; switch (columnTypesExpression.Expression) { case "dd/MM/yyyy hh:mm": datePicker.TimePopupButton.Visible = true; break; case "hh:mm": datePicker.TimePopupButton.Visible = true; datePicker.DatePopupButton.Visible = false; datePicker.ShowPopupOnFocus = false; break; /*case "dd/MM/yyyy": * default: * datePicker.DateInput.DateFormat = columnTypesExpression.Expression; * break;*/ } } if (!string.IsNullOrEmpty(dataValue.Key)) { if (!string.IsNullOrEmpty(dataValue.Value)) { datePicker.SelectedDate = DateTime.Parse(dataValue.Value); } } else if (field.IsAdditional && !string.IsNullOrEmpty(layout.DefaultValue)) { datePicker.SelectedDate = DateTime.Parse(layout.DefaultValue); } if (!string.IsNullOrEmpty(layout.CSSStyle)) { datePicker.DateInput.Attributes.Add("style", ClearBackground(layout.CSSStyle)); } datePicker.ClientEvents.OnPopupOpening = "PopupOpening"; fieldWrapper.Controls.Add(datePicker); container.Controls.Add(fieldWrapper); break; case ColumnType.Enum: var dictionaryComboBox = (DictionaryComboBox)LoadControl("~/UserControls/DictionaryComboBox.ascx"); dictionaryComboBox.ID = controlId; dictionaryComboBox.DataValueField = "ID"; dictionaryComboBox.Skin = skin; if (field.IsAdditional) { dictionaryComboBox.DictionaryName = "tbl_SiteColumnValues"; dictionaryComboBox.DataTextField = "Value"; dictionaryComboBox.Filters.Add(new DictionaryComboBox.DictionaryFilterColumn { DbType = DbType.Guid, Name = "SiteColumnID", Value = field.Value }); if (!string.IsNullOrEmpty(dataValue.Key) && !string.IsNullOrEmpty(dataValue.Value)) { dictionaryComboBox.SelectedId = Guid.Parse(dataValue.Value); } else if (field.IsAdditional && !string.IsNullOrEmpty(layout.DefaultValue)) { dictionaryComboBox.SelectedId = Guid.Parse(layout.DefaultValue); } } else { var order = new List <DictionaryComboBox.DictionaryOrderColumn>(); switch (field.Value) { case "sys_joblevel": dictionaryComboBox.SiteID = siteID; dictionaryComboBox.DictionaryName = "tbl_ContactJobLevel"; dictionaryComboBox.DataTextField = "Name"; order.Add(new DictionaryComboBox.DictionaryOrderColumn { Name = "Name", Direction = "ASC" }); break; case "sys_functionincompany": dictionaryComboBox.SiteID = siteID; dictionaryComboBox.DictionaryName = "tbl_ContactFunctionInCompany"; dictionaryComboBox.DataTextField = "Name"; order.Add(new DictionaryComboBox.DictionaryOrderColumn { Name = "Name", Direction = "ASC" }); break; case "sys_country": dictionaryComboBox.DictionaryName = "tbl_Country"; dictionaryComboBox.DataTextField = "Name"; order.Add(new DictionaryComboBox.DictionaryOrderColumn { Name = "Name", Direction = "ASC" }); break; case "sys_city": dictionaryComboBox.DictionaryName = "tbl_City"; dictionaryComboBox.DataTextField = "Name"; order.Add(new DictionaryComboBox.DictionaryOrderColumn { Name = "Name", Direction = "ASC" }); break; case "sys_advertisingplatform": dictionaryComboBox.SiteID = siteID; dictionaryComboBox.DictionaryName = "tbl_AdvertisingPlatform"; dictionaryComboBox.DataTextField = "Title"; order.Add(new DictionaryComboBox.DictionaryOrderColumn { Name = "Title", Direction = "ASC" }); break; case "sys_advertisingtype": dictionaryComboBox.SiteID = siteID; dictionaryComboBox.DictionaryName = "tbl_AdvertisingType"; dictionaryComboBox.DataTextField = "Title"; order.Add(new DictionaryComboBox.DictionaryOrderColumn { Name = "Title", Direction = "ASC" }); break; case "sys_advertisingcampaign": dictionaryComboBox.SiteID = siteID; dictionaryComboBox.DictionaryName = "tbl_AdvertisingCampaign"; dictionaryComboBox.DataTextField = "Title"; order.Add(new DictionaryComboBox.DictionaryOrderColumn { Name = "Title", Direction = "ASC" }); break; } dictionaryComboBox.Order = order; if (!string.IsNullOrEmpty(dataValue.Value)) { dictionaryComboBox.SelectedId = Guid.Parse(dataValue.Value); } } if (layout.IsRequired) { dictionaryComboBox.ComboBox.OnClientSelectedIndexChanged = "ClientSelectedIndexChanged"; dictionaryComboBox.ValidationGroup = "vg"; } if (!string.IsNullOrEmpty(layout.CSSStyle)) { dictionaryComboBox.ComboBox.Attributes.Add("style", ClearBackground(layout.CSSStyle)); if (IsContainsBackground(layout.CSSStyle)) { dictionaryComboBox.Skin = "Transparent"; } } if ((OutputFormatFields)parentLayout.OutputFormatFields == OutputFormatFields.InElement) { dictionaryComboBox.EmptyItemText = layout.SiteColumnID.HasValue ? layout.SiteColumnName : field.Name; } fieldWrapper.Controls.Add(dictionaryComboBox); container.Controls.Add(fieldWrapper); break; case ColumnType.Logical: var checkBox = new CheckBox { ID = controlId, Width = new Unit(16, UnitType.Pixel) }; if (!checkboxes.Contains(controlId)) { checkboxes.Add(controlId); } if (!string.IsNullOrEmpty(dataValue.Key)) { checkBox.Checked = !string.IsNullOrEmpty(dataValue.Value) ? bool.Parse(dataValue.Value) : false; } else if (field.IsAdditional && !string.IsNullOrEmpty(layout.DefaultValue)) { checkBox.Checked = !string.IsNullOrEmpty(layout.DefaultValue) ? bool.Parse(layout.DefaultValue) : false; } /*if (!string.IsNullOrEmpty(layout.CSSStyle)) * text.Attributes.Add("style", ClearBackground(layout.CSSStyle));*/ fieldWrapper.Controls.Add(checkBox); container.Controls.Add(fieldWrapper); break; } /*if (!string.IsNullOrEmpty(layout.CSSStyle) && layout.CSSStyle.Trim() != string.Empty) * fieldWrapper.Attributes.Add("style", layout.CSSStyle);*/ if (layout.IsRequired && field.ColumnType != ColumnType.Enum) { fieldWrapper.Controls.Add(new RequiredFieldValidator { ControlToValidate = controlId, ErrorMessage = "Поле обязательное для заполнения", Display = ValidatorDisplay.None, ValidationGroup = "vg" }); } if (layout.ColumnTypeExpressionID.HasValue) { if (field.ColumnType != ColumnType.Date) { var columnTypesExpression = repository.ColumnTypesExpression_SelectById((Guid)layout.ColumnTypeExpressionID); fieldWrapper.Controls.Add(new RegularExpressionValidator { ValidationExpression = columnTypesExpression.Expression, ControlToValidate = controlId, ErrorMessage = "Неправильный формат поля", Display = ValidatorDisplay.None, ValidationGroup = "vg" }); } } if (!layout.IsExtraField || (layout.IsExtraField && (siteActivityRule.CountExtraFields == null || siteActivityRule.CountExtraFields > extraFieldCount) && string.IsNullOrEmpty(dataValue.Value))) { controlToInsert.Controls.Add(container); extraFieldCount++; } break; } BuildLayout(siteID, contactID, siteActivityRule, siteActivityRuleLayouts, layout, contactColumnValues, register); } }
/// <summary> /// Binds the data. /// </summary> private void BindData() { if (!string.IsNullOrEmpty(Request.QueryString["sarId"]) && !string.IsNullOrEmpty(Request.QueryString["sId"]) && !string.IsNullOrEmpty(Request.QueryString["cId"])) { ContactId = Guid.Parse(Request.QueryString["cId"]); SiteId = Guid.Parse(Request.QueryString["sId"]); var refferContact = DataManager.Contact.SelectById(SiteId.Value, ContactId.Value); if (refferContact != null) { txtFullName.Text = refferContact.UserFullName; txtEmail.Text = refferContact.Email; } var siteActivityRule = DataManager.SiteActivityRules.SelectById(Guid.Parse(Request.QueryString["sarId"])); if (siteActivityRule != null) { var layout = siteActivityRule.tbl_SiteActivityRuleLayout.FirstOrDefault(o => (LayoutType)o.LayoutType == LayoutType.InviteFriend); if (layout != null) { var layoutParams = LayoutParams.Deserialize(layout.LayoutParams); if (layoutParams.SingleOrDefault(o => o.Name == "SiteActionTemplateID") != null) { Guid _siteActionTemplateId = Guid.Empty; if (!Guid.TryParse(layoutParams.SingleOrDefault(o => o.Name == "SiteActionTemplateID").Value, out _siteActionTemplateId)) { plForm.Visible = false; plMessage.Visible = true; } else { SiteActionTemplateId = _siteActionTemplateId; } } if (layoutParams.SingleOrDefault(o => o.Name == "WorkflowTemplateID") != null) { Guid _workflowTemplateId = Guid.Empty; if (Guid.TryParse(layoutParams.SingleOrDefault(o => o.Name == "WorkflowTemplateID").Value, out _workflowTemplateId)) { WorkflowTemplateId = _workflowTemplateId; } } } var layouts = siteActivityRule.tbl_SiteActivityRuleLayout.Where(o => (LayoutType)o.LayoutType != LayoutType.InviteFriend).OrderBy(o => o.Order).ToList(); if (layouts.Count > 0) { lrlHeaderInstruction.Text = string.Format("<p class=\"instruction\" style=\"{1}\">{0}</p>", layouts[0].Description, layouts[0].CSSStyle); } if (layouts.Count > 1) { lrlFooterInstruction.Text = string.Format("<p class=\"instruction\" style=\"{1}\">{0}</p>", layouts[1].Description, layouts[0].CSSStyle); } if (!string.IsNullOrEmpty(siteActivityRule.TextButton)) { lrlButtonText.Text = siteActivityRule.TextButton; } if (!string.IsNullOrEmpty(siteActivityRule.CSSButton)) { lbtnInviteFriend.Attributes.Add("style", siteActivityRule.CSSButton); } if (!string.IsNullOrEmpty(siteActivityRule.CSSForm)) { plContainer.Attributes.Add("style", siteActivityRule.CSSForm); } } } }
/// <summary> /// Saves the specified site activity rule id. /// </summary> /// <param name="siteActivityRuleId">The site activity rule id.</param> public void Save(Guid siteActivityRuleId) { var dataManager = new DataManager(); var txtFormTitle = ((TextBox)rmpWizard.FindPageViewByID("InstructionAndText").Controls[0].FindControl("txtFormTitle")); var txtTextButton = ((TextBox)rmpWizard.FindPageViewByID("InstructionAndText").Controls[0].FindControl("txtTextButton")); var txtFormWidth = ((RadNumericTextBox)rmpWizard.FindPageViewByID("Design").Controls[0].FindControl("txtFormWidth")); var ucCssEditorInstruction = ((CssEditor)rmpWizard.FindPageViewByID("Design").Controls[0].FindControl("ucCssEditorInstruction")); var ucCssEditorColumns = ((CssEditor)rmpWizard.FindPageViewByID("Design").Controls[0].FindControl("ucCssEditorColumns")); var ucCssEditorButton = ((CssEditor)rmpWizard.FindPageViewByID("Design").Controls[0].FindControl("ucCssEditorButton")); var rcpBackgroundColor = ((RadColorPicker)rmpWizard.FindPageViewByID("Design").Controls[0].FindControl("rcpBackgroundColor")); var txtUrl = ((TextBox)rmpWizard.FindPageViewByID("ActionAfterProcessing").Controls[0].FindControl("txtUrl")); var plInviteFriendSettings = ((Panel)rmpWizard.FindPageViewByID("ActionAfterProcessing").Controls[0].FindControl("plInviteFriendSettings")); var dcbWorkflowTemplate = ((DictionaryOnDemandComboBox)rmpWizard.FindPageViewByID("ActionAfterProcessing").Controls[0].FindControl("dcbWorkflowTemplate")); var ucPopupSiteActionTemplate = ((PopupSiteActionTemplate)rmpWizard.FindPageViewByID("ActionAfterProcessing").Controls[0].FindControl("ucPopupSiteActionTemplate")); tbl_SiteActivityRules siteActivityRule = null; if (!IsEditMode) { siteActivityRule = dataManager.SiteActivityRules.CopyByID(siteActivityRuleId); siteActivityRule.TemplateID = siteActivityRuleId; siteActivityRule.SiteID = CurrentUser.Instance.SiteID; siteActivityRule.Code = string.Concat("form_", DateTime.Now.ToString("[ddMMyyyy]_[mmss]")); var currentSiteColumnCategories = dataManager.ColumnCategories.SelectAll(CurrentUser.Instance.SiteID); foreach (tbl_SiteActivityRuleLayout ruleLayout in siteActivityRule.tbl_SiteActivityRuleLayout) { ruleLayout.SiteID = CurrentUser.Instance.SiteID; } foreach (tbl_SiteColumns siteColumns in dataManager.SiteColumns.SelectByActivityRuleId(siteActivityRule.ID)) { siteColumns.SiteID = CurrentUser.Instance.SiteID; var columnCategory = currentSiteColumnCategories.SingleOrDefault(o => o.Title == siteColumns.tbl_ColumnCategories.Title) ?? currentSiteColumnCategories.FirstOrDefault(); siteColumns.CategoryID = columnCategory.ID; } } else { siteActivityRule = dataManager.SiteActivityRules.SelectById(siteActivityRuleId); } siteActivityRule.Name = txtFormTitle.Text; siteActivityRule.TextButton = txtTextButton.Text; siteActivityRule.RepostURL = txtUrl.Text; siteActivityRule.FormWidth = (int?)txtFormWidth.Value; siteActivityRule.CSSButton = ucCssEditorButton.GetCss(); siteActivityRule.CSSForm = EncodeBackgroundCss(rcpBackgroundColor); var order = 0; var existsiteActivityRule = dataManager.SiteActivityRules.SelectById(siteActivityRuleId); foreach (var activityRuleLayout in existsiteActivityRule.tbl_SiteActivityRuleLayout) { if (string.IsNullOrEmpty(activityRuleLayout.LayoutParams)) { continue; } var toUpdate = siteActivityRule.tbl_SiteActivityRuleLayout.FirstOrDefault(o => o.Name == activityRuleLayout.Name); if (toUpdate == null) { continue; } var lp = LayoutParams.Deserialize(activityRuleLayout.LayoutParams); if (!string.IsNullOrEmpty(lp.GetValue("ShowInMaster"))) { switch ((ShowTextBlockInMaster)int.Parse(lp.GetValue("ShowInMaster"))) { case ShowTextBlockInMaster.Text: var text = ((TextBox)FindControlRecursive(rmpWizard.FindPageViewByID("InstructionAndText").Controls[0], activityRuleLayout.ID.ToString())).Text; text = text.Replace("\n", "#@#"); text = Sanitizer.GetSafeHtmlFragment(text); text = text.Replace("#@#", "\n"); toUpdate.Description = text; break; case ShowTextBlockInMaster.HTML: toUpdate.Description = ((RadEditor)FindControlRecursive(rmpWizard.FindPageViewByID("InstructionAndText").Controls[0], activityRuleLayout.ID.ToString())).Content; break; } toUpdate.CSSStyle = ucCssEditorInstruction.GetCss(); } } foreach (tbl_SiteActivityRuleLayout ruleLayout in siteActivityRule.tbl_SiteActivityRuleLayout) { if (string.IsNullOrEmpty(ruleLayout.LayoutParams) && ruleLayout.LayoutType != (int)LayoutType.Feedback && ruleLayout.LayoutType != (int)LayoutType.GroupFields && ruleLayout.LayoutType != (int)LayoutType.InviteFriend && ruleLayout.LayoutType != (int)LayoutType.Root && ruleLayout.LayoutType != (int)LayoutType.TextBlock) { ruleLayout.CSSStyle = ucCssEditorColumns.GetCss(); } } if (rmpWizard.FindPageViewByID("LogicProcessing") != null) { var ddlOutputFormatFields = ((DropDownList)rmpWizard.FindPageViewByID("LogicProcessing").Controls[0].FindControl("ddlOutputFormatFields")); var rlbDestination = ((RadListBox)rmpWizard.FindPageViewByID("LogicProcessing").Controls[0].FindControl("rlbDestination")); var plFeedBack = ((Panel)rmpWizard.FindPageViewByID("LogicProcessing").Controls[0].FindControl("plFeedBack")); var rblStep = ((RadioButtonList)rmpWizard.FindPageViewByID("LogicProcessing").Controls[0].FindControl("rblStep")); var rblKnowledgeBase = ((RadioButtonList)rmpWizard.FindPageViewByID("LogicProcessing").Controls[0].FindControl("rblKnowledgeBase")); var chxPublicationType = ((CheckBoxList)rmpWizard.FindPageViewByID("LogicProcessing").Controls[0].FindControl("chxPublicationType")); tbl_SiteActivityRuleLayout parentSiteActivityRuleLayout = (from ruleLayout in siteActivityRule.tbl_SiteActivityRuleLayout where !string.IsNullOrEmpty(ruleLayout.LayoutParams) let layoutParams = LayoutParams.Deserialize(ruleLayout.LayoutParams) where !string.IsNullOrEmpty(layoutParams.GetValue("IsUsedForAdditionalDetails")) && bool.Parse(layoutParams.GetValue("IsUsedForAdditionalDetails")) select ruleLayout).FirstOrDefault(); if (parentSiteActivityRuleLayout != null) { var idsToDelete = siteActivityRule.tbl_SiteActivityRuleLayout.Where( o => o.ParentID == parentSiteActivityRuleLayout.ID).Select(o => o.ID).ToList(); foreach (Guid id in idsToDelete) { dataManager.SiteActivityRuleLayout.Delete(id); } foreach (RadListBoxItem item in rlbDestination.Items) { var siteActivityRuleLayout = new tbl_SiteActivityRuleLayout { ID = Guid.NewGuid(), SiteID = CurrentUser.Instance.SiteID, SiteActivityRuleID = siteActivityRule.ID, Order = order, Name = item.Text, ParentID = parentSiteActivityRuleLayout.ID, LayoutType = (int)LayoutType.ProfileField }; Guid outSiteColumnId; if (Guid.TryParse(item.Value, out outSiteColumnId)) { siteActivityRuleLayout.SiteColumnID = outSiteColumnId; siteActivityRuleLayout.SysField = null; } else { siteActivityRuleLayout.SiteColumnID = null; siteActivityRuleLayout.SysField = item.Value; } /*switch (item.Value) * { * case "sys_fullname": * siteActivityRuleLayout.LayoutType = (int) LayoutType.FullName; * break; * case "sys_email": * siteActivityRuleLayout.LayoutType = (int) LayoutType.Email; * break; * case "sys_phone": * siteActivityRuleLayout.LayoutType = (int) LayoutType.Phone; * break; * case "sys_surname": * siteActivityRuleLayout.LayoutType = (int) LayoutType.Surname; * break; * case "sys_name": * siteActivityRuleLayout.LayoutType = (int) LayoutType.Name; * break; * case "sys_patronymic": * siteActivityRuleLayout.LayoutType = (int) LayoutType.Patronymic; * break; * default: * siteActivityRuleLayout.SiteColumnID = Guid.Parse(item.Value); * siteActivityRuleLayout.LayoutType = (int) LayoutType.ProfileField; * break; * }*/ order++; siteActivityRule.tbl_SiteActivityRuleLayout.Add(siteActivityRuleLayout); } parentSiteActivityRuleLayout.OutputFormatFields = int.Parse(ddlOutputFormatFields.SelectedValue); dataManager.SiteActivityRuleLayout.Update(parentSiteActivityRuleLayout); } if (plFeedBack.Visible) { var feedBackComponent = siteActivityRule.tbl_SiteActivityRuleLayout.FirstOrDefault(o => o.LayoutType == (int)LayoutType.Feedback); if (feedBackComponent != null) { var layoutParams = new List <LayoutParams>(); layoutParams.Add(new LayoutParams() { Name = "step", Value = rblStep.SelectedValue }); layoutParams.Add(new LayoutParams() { Name = "kb", Value = rblKnowledgeBase.SelectedValue }); var publicationTypeValues = (from ListItem item in chxPublicationType.Items where item.Selected select item.Value).ToList(); layoutParams.Add(new LayoutParams() { Name = "pt", Value = string.Join(",", publicationTypeValues) }); feedBackComponent.LayoutParams = LayoutParams.Serialize(layoutParams); } } } if (plInviteFriendSettings.Visible) { var inviteFriendComponent = siteActivityRule.tbl_SiteActivityRuleLayout.FirstOrDefault(o => o.LayoutType == (int)LayoutType.InviteFriend); if (inviteFriendComponent != null) { var lp = new List <LayoutParams>(); var item = new LayoutParams { Name = "WorkflowTemplateID", Value = dcbWorkflowTemplate.SelectedIdNullable.HasValue ? dcbWorkflowTemplate.SelectedId.ToString() : string.Empty }; lp.Add(item); item = new LayoutParams { Name = "SiteActionTemplateID", Value = ucPopupSiteActionTemplate.SiteActionTemplateId != Guid.Empty ? ucPopupSiteActionTemplate.SiteActionTemplateId.ToString() : string.Empty }; lp.Add(item); inviteFriendComponent.LayoutParams = LayoutParams.Serialize(lp); } } dataManager.SiteActivityRules.Update(siteActivityRule); Response.Redirect(UrlsData.AP_SiteActivityRules((int)RuleType.ExternalForm)); }