Example #1
0
        /// <summary>
        /// Handles the OnItemDataBound event of the gridLinks 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 gridLinks_OnItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = (GridDataItem)e.Item;
                var data = (DataRowView)e.Item.DataItem;

                ((Literal)item.FindControl("lSubstitutionCode")).Text = string.Format("&lt;a href=\"javascript:WebCounter.LG_Link('{0}')\"&gt;{1}&lt;/a&gt;", data["tbl_Links_Code"], data["tbl_Links_URL"]);
                ((HyperLink)item.FindControl("hlEdit")).NavigateUrl   = UrlsData.AP_SiteActivityRule(Guid.Parse(data["ID"].ToString()), (int)RuleType.Link);
            }
        }
        /// <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);
                }
            }
        }
Example #3
0
 /// <summary>
 /// Handles the OnItemDataBound event of the rgStats 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 rgStats_OnItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridDataItem)
     {
         if (e.Item.OwnerTableView.Name == "Detail")
         {
             var item           = (tbl_SiteActionLink)e.Item.DataItem;
             var hlUserFullName = ((HyperLink)e.Item.FindControl("hlUserFullName"));
             if (!string.IsNullOrEmpty(item.tbl_Contact.UserFullName))
             {
                 ((Literal)e.Item.FindControl("litContact")).Text = string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", UrlsData.AP_Contact(item.tbl_Contact.ID), item.tbl_Contact.UserFullName);
             }
             else
             {
                 ((Literal)e.Item.FindControl("litContact")).Text = string.Format("&lt;<a href=\"{0}\" target=\"_blank\">Незнакомец</a> от {1}&gt;", UrlsData.AP_Contact(item.tbl_Contact.ID), item.tbl_Contact.CreatedAt.ToString("dd.MM.yyyy HH:mm"));
             }
         }
         else
         {
             dynamic siteActionLink = e.Item.DataItem;
             if (siteActionLink.SiteActivityRuleID != null)
             {
                 var siteActivityRule = _dataManager.Links.SelectById((Guid)siteActionLink.SiteActivityRuleID);
                 if (siteActivityRule != null)
                 {
                     ((HyperLink)e.Item.FindControl("hlLink")).Text        = siteActivityRule.Code;
                     ((HyperLink)e.Item.FindControl("hlLink")).NavigateUrl = UrlsData.AP_SiteActivityRule(siteActivityRule.ID, siteActivityRule.RuleTypeID);
                 }
             }
             else if (!string.IsNullOrEmpty(siteActionLink.LinkURL))
             {
                 ((HyperLink)e.Item.FindControl("hlLink")).Text        = siteActionLink.LinkURL;
                 ((HyperLink)e.Item.FindControl("hlLink")).NavigateUrl = siteActionLink.LinkURL;
             }
         }
     }
 }
Example #4
0
        /// <summary>
        /// Handles the ItemDataBound event of the lvSiteActionLink control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.ListViewItemEventArgs"/> instance containing the event data.</param>
        protected void lvSiteActionLink_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                var massMail        = DataManager.MassMail.SelectById(SiteId, _massMailId);
                var massMailContact = DataManager.MassMailContact.SelectByMassMailId(SiteId, _massMailId).Where(a => a.SiteActionID != null).ToList();
                var actionIDs       = massMailContact.Select(a => a.SiteActionID).ToList();

                dynamic siteActionLink = e.Item.DataItem;
                if (siteActionLink.SiteActivityRuleID != null)
                {
                    var siteActivityRule = DataManager.SiteActivityRules.SelectById((Guid)siteActionLink.SiteActivityRuleID);
                    if (siteActivityRule != null)
                    {
                        ((HyperLink)e.Item.FindControl("hlActionLink")).Text        = siteActivityRule.Code;
                        ((HyperLink)e.Item.FindControl("hlActionLink")).NavigateUrl = UrlsData.AP_SiteActivityRule(siteActivityRule.ID, siteActivityRule.RuleTypeID);
                    }
                }
                else if (!string.IsNullOrEmpty(siteActionLink.LinkURL))
                {
                    ((HyperLink)e.Item.FindControl("hlActionLink")).Text        = siteActionLink.LinkURL;
                    ((HyperLink)e.Item.FindControl("hlActionLink")).NavigateUrl = siteActionLink.LinkURL;
                }

                ((Literal)e.Item.FindControl("litCountConversions")).Text = siteActionLink.Count.ToString();

                ((SiteActionLinkUsers)e.Item.FindControl("ucSiteActionLinkUsers")).SiteActionTemplateID = massMail.SiteActionTemplateID;
                ((SiteActionLinkUsers)e.Item.FindControl("ucSiteActionLinkUsers")).SiteActivityRuleID   = siteActionLink.SiteActivityRuleID;
                ((SiteActionLinkUsers)e.Item.FindControl("ucSiteActionLinkUsers")).LinkURL   = siteActionLink.LinkURL;
                ((SiteActionLinkUsers)e.Item.FindControl("ucSiteActionLinkUsers")).ActionIDs = actionIDs;
            }
        }
Example #5
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;

                switch ((MaterialType)data.Type)
                {
                case MaterialType.Url:
                    ((Literal)item.FindControl("litName")).Text  = data.Name;
                    item.FindControl("hlName").Visible           = false;
                    ((Literal)item.FindControl("litValue")).Text = data.Value;
                    break;

                case MaterialType.File:
                    var file = _dataManager.Links.SelectById(data.Value.ToGuid());
                    ((HyperLink)item.FindControl("hlName")).Text        = data.Name;
                    ((HyperLink)item.FindControl("hlName")).NavigateUrl = UrlsData.AP_SiteActivityRule(file.ID, (int)RuleType.File);
                    item.FindControl("litName").Visible          = false;
                    ((Literal)item.FindControl("litValue")).Text = file.Name;
                    break;

                case MaterialType.Form:
                    var siteActivityRule = _dataManager.SiteActivityRules.SelectById(data.Value.ToGuid());
                    ((HyperLink)item.FindControl("hlName")).Text        = data.Name;
                    ((HyperLink)item.FindControl("hlName")).NavigateUrl = UrlsData.AP_SiteActivityRule(siteActivityRule.ID, (MaterialType)data.Type == MaterialType.File ? (int)RuleType.File : (int)RuleType.Form);
                    item.FindControl("litName").Visible          = false;
                    ((Literal)item.FindControl("litValue")).Text = siteActivityRule.Name;
                    break;
                }

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

            if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
            {
                var gridEditFormItem = (GridEditFormItem)e.Item;

                var rblType = (RadioButtonList)gridEditFormItem.FindControl("rblType");
                foreach (var materialType in EnumHelper.EnumToList <MaterialType>())
                {
                    rblType.Items.Add(new ListItem(EnumHelper.GetEnumDescription(materialType), ((int)materialType).ToString()));
                }
                rblType.SelectedIndex = 0;
                rblType.Items.RemoveAt(3); // Удаление Шаблона сообщения

                var dcbFile = ((DictionaryOnDemandComboBox)gridEditFormItem.FindControl("dcbFile"));
                dcbFile.SiteID = _currentUser.SiteID;
                dcbFile.Filters.Add(new DictionaryOnDemandComboBox.DictionaryFilterColumn {
                    Name = "RuleTypeID", DbType = DbType.Int32, Value = ((int)RuleType.File).ToString()
                });
                dcbFile.DataBind();

                var dcbForm = ((DictionaryOnDemandComboBox)gridEditFormItem.FindControl("dcbForm"));
                dcbForm.SiteID = _currentUser.SiteID;
                dcbForm.Filters.Add(new DictionaryOnDemandComboBox.DictionaryFilterColumn {
                    Name = "RuleTypeID", DbType = DbType.Int32, Value = ((int)RuleType.Form).ToString()
                });
                dcbForm.DataBind();

                var rauFile = ((RadAsyncUpload)gridEditFormItem.FindControl("rauFile"));
                rauFile.OnClientFileUploaded      = "fileUploaded";
                rauFile.OnClientFileUploadRemoved = "fileUploadRemoved";

                var data = e.Item.DataItem as MaterialMap;
                if (data != null)
                {
                    rblType.SelectedValue = data.Type.ToString();

                    gridEditFormItem.FindControl("pnlUrl").Visible  = false;
                    gridEditFormItem.FindControl("pnlFile").Visible = false;
                    gridEditFormItem.FindControl("pnlForm").Visible = false;

                    switch ((MaterialType)data.Type)
                    {
                    case MaterialType.Url:
                        gridEditFormItem.FindControl("pnlUrl").Visible = true;
                        break;

                    case MaterialType.File:
                        var siteActivityRuleFile = _dataManager.Links.SelectById(data.Value.ToGuid());
                        dcbFile.SelectedId   = siteActivityRuleFile.ID;
                        dcbFile.SelectedText = siteActivityRuleFile.Name;

                        gridEditFormItem.FindControl("pnlFile").Visible = true;
                        break;

                    case MaterialType.Form:
                        var siteActivityRuleForm = _dataManager.SiteActivityRules.SelectById(data.Value.ToGuid());
                        dcbForm.SelectedId   = siteActivityRuleForm.ID;
                        dcbForm.SelectedText = siteActivityRuleForm.Name;

                        gridEditFormItem.FindControl("pnlForm").Visible = true;
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Handles the OnItemDataBound event of the gridSiteActivityRules 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 gridSiteActivityRules_OnItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = (GridDataItem)e.Item;
                var data = (DataRowView)e.Item.DataItem;

                ((HyperLink)item.FindControl("spanName")).Text = data["tbl_SiteActivityRules_Name"].ToString();

                ((Literal)item.FindControl("lType")).Text = data["tbl_RuleTypes_Title"].ToString();

                ((HyperLink)item.FindControl("urlLink")).Text = data["tbl_SiteActivityRules_URL"].ToString();
                if (!string.IsNullOrEmpty(((HyperLink)item.FindControl("urlLink")).Text))
                {
                    ((HyperLink)item.FindControl("urlLink")).NavigateUrl = ((HyperLink)item.FindControl("urlLink")).Text;
                }
                else
                {
                    item.FindControl("spanUrl").Visible = false;
                }

                ((Literal)item.FindControl("lDescription")).Text = data["tbl_SiteActivityRules_Description"].ToString();

                var lbCopy = (LinkButton)e.Item.FindControl("lbCopy");
                lbCopy.CommandArgument = data["ID"].ToString();
                lbCopy.Command        += new CommandEventHandler(lbCopy_OnCommand);


                var lbDelete = (LinkButton)e.Item.FindControl("lbDelete");
                lbDelete.CommandArgument = data["ID"].ToString();
                lbDelete.Command        += new CommandEventHandler(lbDelete_OnCommand);

                if ((RuleType)int.Parse(data["tbl_SiteActivityRules_RuleTypeID"].ToString()) == RuleType.Form)
                {
                    ((LinkButton)item.FindControl("lbGetScript")).OnClientClick =
                        string.Format("openRadWindow('{0}'); return false;", data["tbl_SiteActivityRules_Code"].ToString());
                    ((LinkButton)item.FindControl("lbGetScript")).Visible = true;
                }

                if ((RuleType)int.Parse(data["tbl_SiteActivityRules_RuleTypeID"].ToString()) == RuleType.WufooForm)
                {
                    ((LinkButton)item.FindControl("lbtnLoadData")).CommandArgument = string.Format("{0}${1}", data["ID"].ToString(),
                                                                                                   !string.IsNullOrEmpty(data["tbl_SiteActivityRules_WufooRevisionDate"].ToString()) ?
                                                                                                   DateTime.Parse((data["tbl_SiteActivityRules_WufooRevisionDate"].ToString())).ToString("yyyy-MM-dd HH:mm:ss") : "");
                    item.FindControl("lbtnLoadData").Visible = true;
                }

                var allowOwnForm = ((LeadForceBasePage)Page).CurrentModuleEditionOptions.SingleOrDefault(a => a.SystemName == "AllowOwnForm");
                if (int.Parse(data["tbl_SiteActivityRules_RuleTypeID"].ToString()) != (int)RuleType.ExternalForm && allowOwnForm == null && !((LeadForceBasePage)Page).IsDefaultEdition)
                {
                    ((HyperLink)item.FindControl("hlEdit")).NavigateUrl   = UrlsData.AP_FormWizard(Guid.Parse(data["ID"].ToString()));
                    ((HyperLink)item.FindControl("spanName")).NavigateUrl = UrlsData.AP_FormWizard(Guid.Parse(data["ID"].ToString()));
                }
                else
                {
                    ((HyperLink)item.FindControl("hlEdit")).NavigateUrl   = UrlsData.AP_SiteActivityRule(Guid.Parse(data["ID"].ToString()), int.Parse(data["tbl_SiteActivityRules_RuleTypeID"].ToString()));
                    ((HyperLink)item.FindControl("spanName")).NavigateUrl = UrlsData.AP_SiteActivityRule(Guid.Parse(data["ID"].ToString()), int.Parse(data["tbl_SiteActivityRules_RuleTypeID"].ToString()));

                    if (int.Parse(data["tbl_SiteActivityRules_RuleTypeID"].ToString()) == (int)RuleType.WufooForm)
                    {
                        lbCopy.Visible = false;
                    }
                }
            }
        }
        protected void gridContactActivity_OnItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = (GridDataItem)e.Item;
                var data = (DataRowView)e.Item.DataItem;

                var target = ((LinkButton)item.FindControl("lbtnShowSessionInfo"));
                if (data["tbl_ContactActivity_ContactSessionID"] != null)
                {
                    rttmSessionInfo.TargetControls.Add(target.ClientID, data["tbl_ContactActivity_ContactSessionID"].ToString(), true);
                }

                target.Text = data["tbl_ContactSessions_UserSessionNumber"] != null && !string.IsNullOrEmpty(data["tbl_ContactSessions_UserSessionNumber"].ToString()) ? "Посещение " + data["tbl_ContactSessions_UserSessionNumber"] : "---";

                if (item.FindControl("lContact") != null)
                {
                    if (!string.IsNullOrEmpty(data["tbl_Contact_UserFullName"].ToString()))
                    {
                        ((Literal)item.FindControl("lContact")).Text = string.Format("<a href=\"{0}\">{1}</a>", UrlsData.AP_Contact(Guid.Parse(data["tbl_Contact_ID"].ToString())), data["tbl_Contact_UserFullName"]);
                    }
                    else
                    {
                        ((Literal)item.FindControl("lContact")).Text = string.Format("&lt;<a href=\"{0}\">Незнакомец</a> от {1}&gt;", UrlsData.AP_Contact(Guid.Parse(data["tbl_Contact_ID"].ToString())), DateTime.Parse(data["tbl_Contact_CreatedAt"].ToString()).ToString("dd.MM.yyyy HH:mm"));
                    }
                }

                if (!string.IsNullOrEmpty(data["tbl_ContactActivity_ActivityCode"].ToString()))
                {
                    switch ((ActivityType)int.Parse(data["tbl_ContactActivity_ActivityTypeID"].ToString()))
                    {
                    case ActivityType.InboxMessage:
                        ((Literal)item.FindControl("lActivityCode")).Text = data["tbl_ContactActivity_ActivityCode"].ToString();
                        break;

                    case ActivityType.ViewPage:
                        ((Literal)item.FindControl("lActivityCode")).Text = string.Format("<a href=\"{0}\" target=\"_blank\">{0}</a>", Server.UrlDecode(data["tbl_ContactActivity_ActivityCode"].ToString()));
                        break;

                    case ActivityType.Link:
                        ((Literal)item.FindControl("lActivityCode")).Text = string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", Server.UrlDecode(data["tbl_ContactActivity_ActivityCode"].ToString()), Server.UrlDecode(data["tbl_ContactActivity_ActivityCode"].ToString()));
                        break;

                    case ActivityType.OpenForm:
                    case ActivityType.FillForm:
                    case ActivityType.CancelForm:
                        var codeForm = data["tbl_ContactActivity_ActivityCode"].ToString();
                        codeForm = Regex.Replace(codeForm, @"^(.*)(#(.*))$", "$1");

                        var siteActivityRuleForm = dataManager.SiteActivityRules.Select(siteID, codeForm);
                        if (siteActivityRuleForm != null)
                        {
                            ((Literal)item.FindControl("lActivityCode")).Text = string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", UrlsData.AP_SiteActivityRule(siteActivityRuleForm.ID, siteActivityRuleForm.RuleTypeID), data["tbl_ContactActivity_ActivityCode"].ToString());
                        }
                        break;

                    case ActivityType.DownloadFile:
                        var siteActivityRule = dataManager.Links.Select(siteID, data["tbl_ContactActivity_ActivityCode"].ToString());
                        if (siteActivityRule != null)
                        {
                            ((Literal)item.FindControl("lActivityCode")).Text = string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", UrlsData.AP_SiteActivityRule(siteActivityRule.ID, siteActivityRule.RuleTypeID), siteActivityRule.Code);
                        }
                        break;

                    /*case ActivityType.Event:
                     *  var siteEventTemplate = dataManager.SiteEventTemplates.SelectById(Guid.Parse(data["tbl_ContactActivity_ActivityCode"].ToString()));
                     *  if (siteEventTemplate != null)
                     *      ((Literal)item.FindControl("lActivityCode")).Text = string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", UrlsData.AP_SiteEventTemplate(siteEventTemplate.ID), siteEventTemplate.Title);
                     *  ((Literal)item.FindControl("lActivityCode")).Text = siteEventTemplate.Title;
                     *  break;*/
                    case ActivityType.UserEvent:
                        var workflow = dataManager.WorkflowElement.SelectByValue(data["tbl_ContactActivity_ID"].ToString());
                        if (workflow != null)
                        {
                            ((Literal)item.FindControl("lActivityCode")).Text = string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", UrlsData.AP_WorkflowEdit(workflow.WorkflowID), data["tbl_ContactActivity_ActivityCode"]);
                        }
                        else
                        {
                            ((Literal)item.FindControl("lActivityCode")).Text = data["tbl_ContactActivity_ActivityCode"].ToString();
                        }
                        break;
                    }
                }
            }
        }
Example #8
0
        /// <summary>
        /// Handles the OnItemDataBound event of the gridSiteActivityRules 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 gridSiteActivityRules_OnItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = (GridDataItem)e.Item;
                var data = (DataRowView)e.Item.DataItem;

                if ((RuleType)int.Parse(data["tbl_SiteActivityRules_RuleTypeID"].ToString()) == RuleType.Link ||
                    (RuleType)int.Parse(data["tbl_SiteActivityRules_RuleTypeID"].ToString()) == RuleType.File)
                {
                    ((Literal)item.FindControl("lSubstitutionCode")).Text = string.Format("&lt;a href=\"javascript:WebCounter.LG_Link('{0}')\"&gt;{1}&lt;/a&gt;", data["tbl_SiteActivityRules_Code"], data["tbl_SiteActivityRules_URL"]);
                }

                if ((RuleType)int.Parse(data["tbl_SiteActivityRules_RuleTypeID"].ToString()) == RuleType.Form)
                {
                    var aGetCode = (HtmlAnchor)item.FindControl("aGetCode");
                    aGetCode.Visible = true;
                    aGetCode.Attributes.Add("onclick", string.Format("openRadWindow('{0}'); return false;", data["tbl_SiteActivityRules_Code"]));
                }

                ((HyperLink)item.FindControl("hlEdit")).NavigateUrl = _ruleTypeId != 0 ? UrlsData.AP_SiteActivityRule(Guid.Parse(data["ID"].ToString()), _ruleTypeId) : UrlsData.AP_SiteActivityRule(Guid.Parse(data["ID"].ToString()), int.Parse(data["tbl_SiteActivityRules_RuleTypeID"].ToString()));
            }
        }