/// <summary>
        /// Handles the OnCommand event of the lbCopy control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.CommandEventArgs"/> instance containing the event data.</param>
        protected void lbCopy_OnCommand(object sender, CommandEventArgs e)
        {
            var newSiteActivityRule = new tbl_SiteActivityRules();
            var _id = Guid.Parse(e.CommandArgument.ToString());

            newSiteActivityRule = _dataManager.SiteActivityRules.CopyByID(_id);

            Response.Redirect(UrlsData.AP_SiteActivityRules((int)RuleType.Form));
            //gridSiteActivityRules.Rebind();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the specified site activity rules.
        /// </summary>
        /// <param name="siteActivityRules">The site activity rules.</param>
        /// <returns></returns>
        public tbl_SiteActivityRules Add(tbl_SiteActivityRules siteActivityRules)
        {
            if (siteActivityRules.ID == Guid.Empty)
            {
                siteActivityRules.ID = Guid.NewGuid();
            }
            _dataContext.tbl_SiteActivityRules.AddObject(siteActivityRules);
            _dataContext.SaveChanges();

            return(siteActivityRules);
        }
Exemplo n.º 3
0
        /// <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();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Proceeds the site activity rule.
        /// </summary>
        /// <param name="siteActivityRule">The site activity rule.</param>
        private void ProceedSiteActivityRule(tbl_SiteActivityRules siteActivityRule)
        {
            if (siteActivityRule == null)
            {
                return;
            }

            if (siteActivityRule.tbl_SiteActivityRuleLayout.Any(o => o.LayoutType == (int)LayoutType.Feedback))
            {
                plColumns.Visible     = false;
                plInstruction.Visible = false;
            }
            if (siteActivityRule.tbl_SiteActivityRuleLayout.Any(o => o.LayoutType == (int)LayoutType.InviteFriend))
            {
                plColumns.Visible = false;
            }
        }
        /// <summary>
        /// Handles the OnClick event of the lbntAddWufooForm 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 lbntAddWufooForm_OnClick(object sender, EventArgs e)
        {
            ucNotificationMessage.Text = string.Empty;

            try
            {
                var client    = new WufooClient(txtWufooName.Text, txtWufooAPIKey.Text);
                var wufooForm = client.GetAllForms().FirstOrDefault(o => o.Hash == txtCode.Text);

                var form = _dataManager.SiteActivityRules.SelectFormByCode(siteID, wufooForm.Hash);

                if (form == null)
                {
                    form = new tbl_SiteActivityRules
                    {
                        SiteID      = siteID,
                        Name        = wufooForm.Name,
                        RuleTypeID  = (int)RuleType.WufooForm,
                        Code        = wufooForm.Hash,
                        Description = wufooForm.Description,
                        WufooAPIKey = txtWufooAPIKey.Text,
                        WufooName   = txtWufooName.Text
                    };

                    _dataManager.SiteActivityRules.Add(form);

                    Response.Redirect(UrlsData.AP_SiteActivityRule(form.ID, (int)RuleType.WufooForm), false);
                }
                else
                {
                    ucNotificationMessage.Text = "Данная форма уже добавлена в систему.";
                }
            }
            catch (Exception ex)
            {
                Log.Error("Ошибка добавления формы Wufoo", ex);
                ucNotificationMessage.Text = "Ошибка загрузки формы Wufoo. Проверьте введенные данные.";

                if (!Page.ClientScript.IsStartupScriptRegistered("AutoHeight"))
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "AutoHeight", "AutoHeight();", true);
                }
            }
        }
Exemplo n.º 6
0
        /// <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);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Handles the OnItemDataBound event of the rgMaterials control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.GridItemEventArgs"/> instance containing the event data.</param>
        protected void rgMaterials_OnItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = (GridDataItem)e.Item;
                var data = (MaterialMap)e.Item.DataItem;

                if (!string.IsNullOrEmpty(data.Description))
                {
                    ((Literal)item.FindControl("litDescription")).Text = data.Description + "<br />";
                }

                if (item.FindControl("pnlUrl") != null)
                {
                    item.FindControl("pnlUrl").Visible = false;
                }
                if (item.FindControl("pnlFile") != null)
                {
                    item.FindControl("pnlFile").Visible = false;
                }
                if (item.FindControl("pnlForm") != null)
                {
                    item.FindControl("pnlForm").Visible = false;
                }

                ((Literal)item.FindControl("litType")).Text = EnumHelper.GetEnumDescription((MaterialType)data.Type);

                switch ((MaterialType)data.Type)
                {
                case MaterialType.Url:
                    ((Literal)item.FindControl("litName")).Text = data.Name;

                    if ((Literal)item.FindControl("litValue") != null)
                    {
                        ((Literal)item.FindControl("litValue")).Text = data.Value;
                    }

                    if ((TextBox)item.FindControl("txtValue") != null)
                    {
                        ((TextBox)item.FindControl("txtValue")).Text = data.Value;
                    }
                    if (item.FindControl("pnlUrl") != null)
                    {
                        item.FindControl("pnlUrl").Visible = true;
                    }
                    break;

                case MaterialType.File:
                    var siteActivityRuleFile = DataManager.Links.SelectById(data.Value.ToGuid());

                    ((Literal)item.FindControl("litName")).Text = data.Name;

                    if ((Literal)item.FindControl("litValue") != null)
                    {
                        ((Literal)item.FindControl("litValue")).Text = siteActivityRuleFile.Name;
                    }

                    var dcbFile = ((DictionaryOnDemandComboBox)item.FindControl("dcbFile"));
                    if (dcbFile != null)
                    {
                        dcbFile.SiteID = CurrentUser.Instance.SiteID;
                        dcbFile.Filters.Add(new DictionaryOnDemandComboBox.DictionaryFilterColumn {
                            Name = "RuleTypeID", DbType = DbType.Int32, Value = ((int)RuleType.File).ToString()
                        });
                        dcbFile.DataBind();

                        if (IsEditMode)
                        {
                            dcbFile.SelectedId = siteActivityRuleFile.ID;
                        }
                        dcbFile.SelectedText = siteActivityRuleFile.Name;
                    }
                    if (item.FindControl("pnlFile") != null)
                    {
                        item.FindControl("pnlFile").Visible = true;
                    }
                    break;

                case MaterialType.Form:
                    ((Literal)item.FindControl("litName")).Text = data.Name;

                    tbl_SiteActivityRules siteActivityRuleForm = null;
                    if (data.Value != null)
                    {
                        siteActivityRuleForm = DataManager.SiteActivityRules.SelectById(data.Value.ToGuid());

                        if ((Literal)item.FindControl("litValue") != null)
                        {
                            ((Literal)item.FindControl("litValue")).Text = siteActivityRuleForm.Name;
                        }
                    }
                    else
                    {
                        if ((Literal)item.FindControl("litValue") != null)
                        {
                            ((Literal)item.FindControl("litValue")).Text = "Выберите форму";
                        }
                    }


                    var dcbForm = ((DictionaryOnDemandComboBox)item.FindControl("dcbForm"));
                    if (dcbForm != null)
                    {
                        dcbForm.SiteID = CurrentUser.Instance.SiteID;
                        dcbForm.Filters.Add(new DictionaryOnDemandComboBox.DictionaryFilterColumn {
                            Name = "RuleTypeID", DbType = DbType.Int32, Value = ((int)RuleType.Form).ToString()
                        });
                        dcbForm.DataBind();

                        if (siteActivityRuleForm != null)
                        {
                            if (IsEditMode)
                            {
                                dcbForm.SelectedId = siteActivityRuleForm.ID;
                            }
                            dcbForm.SelectedText = siteActivityRuleForm.Name;
                        }
                    }

                    if (item.FindControl("pnlForm") != null)
                    {
                        item.FindControl("pnlForm").Visible = true;
                    }
                    break;

                case MaterialType.ActionTemplate:
                    ((Literal)item.FindControl("litName")).Text = data.Name;

                    var oldValue           = data.OldValue.ToGuid();
                    var siteActionTemplate = SiteActionTemplateList.FirstOrDefault(a => a.ID == oldValue);
                    ((Literal)item.FindControl("litValue")).Text = siteActionTemplate.Title;
                    break;
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Deletes the by ID.
        /// </summary>
        /// <param name="id">The id.</param>
        public tbl_SiteActivityRules CopyByID(Guid id)
        {
            var siteActivityRule = SelectById(id);

            if (siteActivityRule != null)
            {
                var newSiteActivityRule = new tbl_SiteActivityRules();
                newSiteActivityRule = siteActivityRule;
                _dataContext.Detach(newSiteActivityRule);
                newSiteActivityRule.ID = new Guid();
                newSiteActivityRule    = Add(newSiteActivityRule);
                NameValueCollection id2id = new NameValueCollection();
                var ruleLayouts           = _dataContext.tbl_SiteActivityRuleLayout.Where(a => a.SiteActivityRuleID == id).OrderBy(a => a.Order);
                if (ruleLayouts.Any())
                {
                    foreach (var ruleLayout in ruleLayouts)
                    {
                        _dataContext.Detach(ruleLayout);
                        var newId = Guid.NewGuid();
                        id2id.Add(ruleLayout.ID.ToString(), newId.ToString());
                        ruleLayout.ID = newId;
                        ruleLayout.SiteActivityRuleID = newSiteActivityRule.ID;
                        string newParrentId = id2id[ruleLayout.ParentID.ToString()];
                        if (newParrentId != null)
                        {
                            ruleLayout.ParentID = Guid.Parse(newParrentId);
                        }

                        _dataContext.tbl_SiteActivityRuleLayout.AddObject(ruleLayout);
                    }

                    _dataContext.SaveChanges();
                }
                //ruleLayouts = _dataContext.tbl_SiteActivityRuleLayout.Where(a => a.SiteActivityRuleID == newSiteActivityRule.ID).OrderBy(a => a.Order);
                //if (ruleLayouts.Any())
                //{
                //    foreach (var ruleLayout in ruleLayouts)
                //    {
                //        if (ruleLayout.ParentID != null)
                //        {
                //            string newParrentId = id2id[ruleLayout.ParentID.ToString()];
                //            if (newParrentId != null)
                //            {
                //                ruleLayout.ParentID = Guid.Parse(newParrentId);
                //            }
                //        }
                //    }
                //}

                var siteColumns = _dataContext.tbl_SiteColumns.Where(a => a.SiteActivityRuleID == id);
                if (siteColumns.Any())
                {
                    foreach (var siteColumn in siteColumns)
                    {
                        _dataContext.Detach(siteColumn);
                        var oldId = siteColumn.ID;
                        siteColumn.ID = Guid.NewGuid();
                        siteColumn.SiteActivityRuleID = newSiteActivityRule.ID;
                        _dataContext.tbl_SiteColumns.AddObject(siteColumn);
                        var siteColumnValues = _dataContext.tbl_SiteColumnValues.Where(a => a.SiteColumnID == oldId);
                        if (siteColumnValues.Any())
                        {
                            foreach (var siteColumnValue in siteColumnValues)
                            {
                                _dataContext.Detach(siteColumnValue);
                                siteColumnValue.ID           = Guid.NewGuid();
                                siteColumnValue.SiteColumnID = siteColumn.ID;
                                _dataContext.tbl_SiteColumns.AddObject(siteColumn);
                            }
                        }

                        foreach (var activityRuleLayout in _dataContext.tbl_SiteActivityRuleLayout.Where(o => o.SiteActivityRuleID == newSiteActivityRule.ID && o.SiteColumnID == oldId))
                        {
                            activityRuleLayout.SiteColumnID = siteColumn.ID;
                        }
                    }
                }
                var siteActivityRuleExternalForms = _dataContext.tbl_SiteActivityRuleExternalForms.Where(a => a.SiteActivityRuleID == id);
                if (siteActivityRuleExternalForms.Any())
                {
                    foreach (var siteActivityRuleExternalForm in siteActivityRuleExternalForms)
                    {
                        _dataContext.Detach(siteActivityRuleExternalForm);
                        var oldId = siteActivityRuleExternalForm.ID;
                        siteActivityRuleExternalForm.ID = Guid.NewGuid();
                        siteActivityRuleExternalForm.SiteActivityRuleID = newSiteActivityRule.ID;
                        _dataContext.tbl_SiteActivityRuleExternalForms.AddObject(siteActivityRuleExternalForm);
                        var siteActivityRuleExternalFormFields = _dataContext.tbl_SiteActivityRuleExternalFormFields.Where(a => a.SiteActivityRuleExternalFormID == oldId);
                        if (siteActivityRuleExternalFormFields.Any())
                        {
                            foreach (var siteActivityRuleExternalFormField in siteActivityRuleExternalFormFields)
                            {
                                _dataContext.Detach(siteActivityRuleExternalFormField);
                                siteActivityRuleExternalFormField.ID = Guid.NewGuid();
                                siteActivityRuleExternalFormField.SiteActivityRuleExternalFormID = siteActivityRuleExternalForm.ID;
                                _dataContext.tbl_SiteActivityRuleExternalFormFields.AddObject(siteActivityRuleExternalFormField);
                            }
                        }
                    }
                }
                _dataContext.SaveChanges();
                return(newSiteActivityRule);
            }
            return(new tbl_SiteActivityRules());
        }
Exemplo n.º 9
0
 /// <summary>
 /// Updates the specified site user.
 /// </summary>
 /// <param name="siteUser">The site user.</param>
 public void Update(tbl_SiteActivityRules siteUser)
 {
     _dataContext.SaveChanges();
 }
Exemplo n.º 10
0
        public void ProceedResources(tbl_SiteActivityRules siteActivityRules)
        {
            var externalResources = repository.ExternalResource_SelectByDestinationID(siteActivityRules.ID);

            if (!externalResources.Any())
            {
                return;
            }

            foreach (var resource in externalResources)
            {
                switch ((ExternalResourceType)resource.ExternalResourceTypeID)
                {
                case ExternalResourceType.JavaScript:
                    var result = string.Empty;
                    if (!string.IsNullOrEmpty(resource.File))
                    {
                        var fsp      = new FileSystemProvider();
                        var filePath = fsp.GetRemoteLink(siteActivityRules.SiteID, "ExternalResource", resource.File, FileType.Attachment);
                        result += string.Format(@"<script type=""text/javascript"" src=""{0}""></script>", filePath);
                    }
                    if (!string.IsNullOrEmpty(resource.Url))
                    {
                        result += string.Format(@"<script type=""text/javascript"" src=""{0}""></script>", resource.Url);
                    }
                    if (!string.IsNullOrEmpty(resource.Text))
                    {
                        if (!resource.Text.Contains("<script"))
                        {
                            result += string.Format(@"<script type=""text/javascript"">{0}</script>", resource.Text);
                        }
                        else
                        {
                            result += resource.Text;
                        }
                    }

                    PutToPlace((ResourcePlace)resource.ResourcePlaceID, result);
                    break;

                case ExternalResourceType.CSS:
                    var css = string.Empty;
                    if (!string.IsNullOrEmpty(resource.File))
                    {
                        var fsp      = new FileSystemProvider();
                        var filePath = fsp.GetRemoteLink(siteActivityRules.SiteID, "ExternalResource", resource.File, FileType.Attachment);
                        css += string.Format(@"<link rel=""stylesheet"" type=""text/css"" href=""{0}"" />", filePath);
                    }
                    if (!string.IsNullOrEmpty(resource.Url))
                    {
                        css += string.Format(@"<link rel=""stylesheet"" type=""text/css"" href=""{0}"" />", resource.Url);
                    }
                    if (!string.IsNullOrEmpty(resource.Text))
                    {
                        if (!resource.Text.Contains("<style"))
                        {
                            css += string.Format(@"<style type=""text/css"">{0}</style>", resource.Text);
                        }
                        else
                        {
                            css += resource.Text;
                        }
                    }

                    PutToPlace((ResourcePlace)resource.ResourcePlaceID, css);
                    break;
                }
            }
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        /// <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));
        }