/// <summary> /// Handles the OnItemDataBound event of the gridMassMails 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 gridMassMails_OnItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { if (access == null) { access = Access.Check(); } var item = (GridDataItem)e.Item; var data = (DataRowView)e.Item.DataItem; var litStatus = (Literal)item.FindControl("litStatus"); litStatus.Text = EnumHelper.GetEnumDescription((MassMailStatus)data["tbl_MassMail_MassMailStatusID"].ToString().ToInt()); ((HyperLink)item.FindControl("spanName")).Text = data["tbl_MassMail_Name"].ToString(); ((HyperLink)item.FindControl("spanName")).NavigateUrl = UrlsData.AP_MassMail(Guid.Parse(data["ID"].ToString())); ((Literal)item.FindControl("lMailDate")).Text = data["tbl_MassMail_MailDate"].ToString(); var lbEdit = (LinkButton)e.Item.FindControl("lbEdit"); lbEdit.CommandArgument = data["ID"].ToString(); lbEdit.Command += new CommandEventHandler(lbEdit_OnCommand); var lbDelete = (LinkButton)e.Item.FindControl("lbDelete"); lbDelete.CommandArgument = data["ID"].ToString(); lbDelete.Command += new CommandEventHandler(lbDelete_OnCommand); lbDelete.Visible = access.Delete; } }
/// <summary> /// Handles the Click event of the BtnSend 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 BtnSend_Click(object sender, EventArgs e) { if (!access.Write) { return; } var massMail = DataManager.MassMail.SelectById(SiteId, _massMailId); massMail.SiteID = SiteId; massMail.Name = ((TextBox)fvMassMail.FindControl("txtName")).Text; massMail.MailDate = DateTime.Now; //massMail.SiteActionTemplateID = Guid.Parse(((TextBox)fvMassMail.FindControl("txtSiteActionTemplateId")).Text); massMail.SiteActionTemplateID = (Guid)((UserControls.SiteActionTemplate)fvMassMail.FindControl("ucSiteActionTemplate")).SelectedSiteActionTemplateId; ((UserControls.SiteActionTemplate)fvMassMail.FindControl("ucSiteActionTemplate")).UpdateSiteActionTemplate(massMail.ID, massMail.SiteActionTemplateID); massMail.MassMailStatusID = (int)MassMailStatusType.Done; if (!string.IsNullOrEmpty(((TextBox)fvMassMail.FindControl("txtFocusGroup")).Text)) { massMail.FocusGroup = int.Parse(((TextBox)fvMassMail.FindControl("txtFocusGroup")).Text); } DataManager.MassMail.Update(massMail); var massMailContacts = DataManager.MassMailContact.SelectByMassMailId(SiteId, _massMailId).Where(a => a.SiteActionID == null); var siteAction = new tbl_SiteAction(); foreach (var massMailContact in massMailContacts) { siteAction = new tbl_SiteAction(); siteAction.SiteID = SiteId; siteAction.SiteActionTemplateID = massMail.SiteActionTemplateID; siteAction.ContactID = massMailContact.ContactID; siteAction.ObjectID = massMail.ID; siteAction.MessageTypeID = (int)MessageType.MassMail; siteAction.ActionStatusID = (int)ActionStatus.Scheduled; siteAction.ActionDate = DateTime.Now; siteAction.OwnerID = CurrentUser.Instance.ContactID; DataManager.SiteAction.Add(siteAction); massMailContact.SiteActionID = siteAction.ID; DataManager.MassMailContact.Update(massMailContact); } //BindData(); Response.Redirect(UrlsData.AP_MassMail(massMail.ID)); }
/// <summary> /// Handles the Click event of the BtnSave 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 BtnSave_Click(object sender, EventArgs e) { if (!access.Write) { return; } var massMail = new tbl_MassMail(); if (_massMailId != Guid.Empty) { massMail = DataManager.MassMail.SelectById(SiteId, _massMailId); } massMail.SiteID = SiteId; massMail.Name = ((TextBox)fvMassMail.FindControl("txtName")).Text; //massMail.SiteActionTemplateID = (Guid)((UserControls.SiteActionTemplate)fvMassMail.FindControl("ucSiteActionTemplate")).SelectedSiteActionTemplateId; massMail.SiteActionTemplateID = ((SelectSiteActionTemplate)fvMassMail.FindControl("ucSelectSiteActionTemplate")).SiteActionTemplateId; massMail.MassMailStatusID = int.Parse(((DropDownList)fvMassMail.FindControl("ddlMassMailStatus")).SelectedValue); if (!string.IsNullOrEmpty(((TextBox)fvMassMail.FindControl("txtFocusGroup")).Text)) { massMail.FocusGroup = int.Parse(((TextBox)fvMassMail.FindControl("txtFocusGroup")).Text); } if (_massMailId != Guid.Empty) { DataManager.MassMail.Update(massMail); } else { massMail.OwnerID = CurrentUser.Instance.ContactID; massMail = DataManager.MassMail.Add(massMail); } //((UserControls.SiteActionTemplate)fvMassMail.FindControl("ucSiteActionTemplate")).UpdateSiteActionTemplate(massMail.ID, massMail.SiteActionTemplateID); tagsMassMail.SaveTags(massMail.ID); Response.Redirect(UrlsData.AP_MassMail(massMail.ID)); }
/// <summary> /// Binds the data. /// </summary> /// <param name="siteActionTemplateId">The site action template id.</param> private void BindData(Guid?siteActionTemplateId) { var siteId = ((LeadForceBasePage)Page).SiteId; plNotBase.Visible = false; dcbParentTemplate.SelectedId = Guid.Empty; dcbParentTemplate.SelectedText = string.Empty; dcbParentTemplate.SiteID = siteId; ddlReplaceLinks.Items.Clear(); EnumHelper.EnumToDropDownList <ReplaceLinks>(ref ddlReplaceLinks, false); rUserColumnValues.DataSource = DataManager.SiteColumns.SelectAll(siteId); rUserColumnValues.DataBind(); ddlActionType.DataSource = DataManager.ActionTypes.SelectAll(); ddlActionType.DataTextField = "Title"; ddlActionType.DataValueField = "ID"; ddlActionType.DataBind(); if (siteActionTemplateId.HasValue) { rtsTabs.Tabs[1].Selected = true; RadMultiPage1.PageViews[1].Selected = true; var siteActionTemplate = DataManager.SiteActionTemplate.SelectById(siteId, (Guid)siteActionTemplateId); if (siteActionTemplate != null) { dcbParentTemplate.Filters.Add(new DictionaryOnDemandComboBox.DictionaryFilterColumn { Name = "ID", DbType = DbType.Guid, Operation = FilterOperation.NotEqual, Value = siteActionTemplate.ID.ToString() }); if (siteActionTemplate.UsageID.HasValue && siteActionTemplate.SiteActionTemplateCategoryID.HasValue) { switch ((SiteActionTemplateCategory)siteActionTemplate.SiteActionTemplateCategoryID) { case SiteActionTemplateCategory.MassMail: var massMail = DataManager.MassMail.SelectById(siteId, (Guid)siteActionTemplate.UsageID); if (massMail != null) { hlUsage.NavigateUrl = UrlsData.AP_MassMail(massMail.ID); hlUsage.Text = massMail.Name; } break; case SiteActionTemplateCategory.Workflow: var workflowTemplate = DataManager.WorkflowTemplate.SelectById(siteId, (Guid)siteActionTemplate.UsageID); if (workflowTemplate != null) { hlUsage.NavigateUrl = UrlsData.AP_WorkflowTemplateEdit(workflowTemplate.ID); hlUsage.Text = workflowTemplate.Name; } break; case SiteActionTemplateCategory.Event: var siteEventTemplate = DataManager.SiteEventTemplates.SelectById((Guid)siteActionTemplate.UsageID); if (siteEventTemplate != null) { hlUsage.NavigateUrl = UrlsData.AP_SiteEventTemplate(siteEventTemplate.ID); hlUsage.Text = siteEventTemplate.Title; } break; } } if (siteActionTemplate.SiteActionTemplateCategoryID.HasValue && siteActionTemplate.SiteActionTemplateCategoryID != (int)SiteActionTemplateCategory.BaseTemplate) { plNotBase.Visible = true; } ddlActionType.SelectedIndex = ddlActionType.FindItemIndexByValue(siteActionTemplate.ActionTypeID.ToString()); ddlReplaceLinks.SelectedIndex = ddlReplaceLinks.FindItemIndexByValue(siteActionTemplate.ReplaceLinksID.ToString()); txtFromEmail.Text = siteActionTemplate.FromEmail; txtFromName.Text = siteActionTemplate.FromName; txtToEmail.Text = siteActionTemplate.ToEmail; txtReplyEmail.Text = siteActionTemplate.ReplyToEmail; txtReplyName.Text = siteActionTemplate.ReplyToName; txtMessageCaption.Text = siteActionTemplate.MessageCaption; ucHtmlEditor.Content = siteActionTemplate.MessageBody; } } }
protected void lbEdit_OnCommand(object sender, CommandEventArgs e) { Response.Redirect(UrlsData.AP_MassMail(Guid.Parse(e.CommandArgument.ToString()))); }
/// <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) { Title = "Шаблоны сообщений - LeadForce"; access = Access.Check(); if (!access.Write) { BtnUpdate.Visible = false; } var siteActionTemplateId = Page.RouteData.Values["ID"] as string; siteID = ((LeadForceBasePage)Page).SiteId; hlCancel.NavigateUrl = UrlsData.AP_SiteActionTemplates(); if (!string.IsNullOrEmpty(siteActionTemplateId)) { Guid.TryParse(siteActionTemplateId, out _siteActionTemplateId); } ucSelectSiteActionTemplate.SiteActionTemplateId = _siteActionTemplateId; if (!Page.IsPostBack) { BindData(); var ddlSiteTemplateCategory = ((DropDownList)fvSiteActionTemplate.FindControl("ddlSiteTemplateCategory")); EnumHelper.EnumToDropDownList <SiteActionTemplateCategory>(ref ddlSiteTemplateCategory, false); var dcbParentTemplate = ((DictionaryOnDemandComboBox)fvSiteActionTemplate.FindControl("dcbParentTemplate")); dcbParentTemplate.SiteID = siteID; dcbParentTemplate.Filters.Add(new DictionaryOnDemandComboBox.DictionaryFilterColumn { Name = "ID", DbType = DbType.Guid, Operation = FilterOperation.NotEqual, Value = _siteActionTemplateId.ToString() }); var siteActionTemplate = DataManager.SiteActionTemplate.SelectById(_siteActionTemplateId); ((DropDownList)fvSiteActionTemplate.FindControl("ddlActionType")).DataSource = DataManager.ActionTypes.SelectAll(); ((DropDownList)fvSiteActionTemplate.FindControl("ddlActionType")).DataTextField = "Title"; ((DropDownList)fvSiteActionTemplate.FindControl("ddlActionType")).DataValueField = "ID"; (fvSiteActionTemplate.FindControl("ddlActionType")).DataBind(); BindReplaceLinks(); var ddlReplaceLinks = ((DropDownList)fvSiteActionTemplate.FindControl("ddlReplaceLinks")); ddlReplaceLinks.SelectedIndex = ddlReplaceLinks.Items.IndexOf(ddlReplaceLinks.Items.FindByValue(((int)ReplaceLinks.GoogleLinks).ToString())); if (_siteActionTemplateId != Guid.Empty && siteActionTemplate != null) { ddlSiteTemplateCategory.SelectedIndex = ddlSiteTemplateCategory.FindItemIndexByValue( siteActionTemplate.SiteActionTemplateCategoryID.ToString()); if (siteActionTemplate.SiteActionTemplateCategoryID.HasValue) { if (siteActionTemplate.UsageID.HasValue) { var hlUsage = ((HyperLink)fvSiteActionTemplate.FindControl("hlUsage")); switch ((SiteActionTemplateCategory)siteActionTemplate.SiteActionTemplateCategoryID) { case SiteActionTemplateCategory.MassMail: var massMail = DataManager.MassMail.SelectById(siteID, (Guid)siteActionTemplate.UsageID); if (massMail != null) { hlUsage.NavigateUrl = UrlsData.AP_MassMail(massMail.ID); hlUsage.Text = massMail.Name; } break; case SiteActionTemplateCategory.Workflow: var workflowTemplate = DataManager.WorkflowTemplate.SelectById(siteID, (Guid)siteActionTemplate.UsageID); if (workflowTemplate != null) { hlUsage.NavigateUrl = UrlsData.AP_WorkflowTemplateEdit(workflowTemplate.ID); hlUsage.Text = workflowTemplate.Name; } break; case SiteActionTemplateCategory.Event: var siteEventTemplate = DataManager.SiteEventTemplates.SelectById((Guid)siteActionTemplate.UsageID); if (siteEventTemplate != null) { hlUsage.NavigateUrl = UrlsData.AP_SiteEventTemplate(siteEventTemplate.ID); hlUsage.Text = siteEventTemplate.Title; } break; } } if (siteActionTemplate.SiteActionTemplateCategoryID != (int)SiteActionTemplateCategory.BaseTemplate) { fvSiteActionTemplate.FindControl("plNotBase").Visible = true; } } if (siteActionTemplate.ParentID.HasValue) { var parentSiteAction = DataManager.SiteActionTemplate.SelectById(siteActionTemplate.ID); dcbParentTemplate.SelectedId = parentSiteAction.ID; dcbParentTemplate.SelectedText = parentSiteAction.Title; dcbParentTemplate.Enabled = true; } ((DropDownList)fvSiteActionTemplate.FindControl("ddlActionType")).Items.FindByValue(siteActionTemplate.ActionTypeID.ToString()).Selected = true; ddlReplaceLinks.SelectedIndex = ddlReplaceLinks.Items.IndexOf(ddlReplaceLinks.Items.FindByValue(siteActionTemplate.ReplaceLinksID.ToString())); if ((ActionType)siteActionTemplate.ActionTypeID == ActionType.EmailToFixed) { (fvSiteActionTemplate.FindControl("pToEmail")).Visible = true; } var siteActions = DataManager.SiteAction.SelectBySiteActionTemplateID(siteID, _siteActionTemplateId).Where(a => (ActionStatus)a.ActionStatusID == ActionStatus.Done).ToList(); if (siteActions != null) { var sendingCount = siteActions.Count; var resoponseCount = siteActions.Count(a => a.ResponseDate != null); litSending.Text = sendingCount.ToString(); litResponse.Text = resoponseCount.ToString(); if (resoponseCount != 0) { litConversion.Text = string.Format("{0}%", Math.Round(((double)resoponseCount / sendingCount) * 100, 2)); } BindActionLinks(); } } else { pStats.Visible = false; rtsTabs.FindTabByValue("tab-action-links").Visible = false; } rUserColumnValues.DataSource = DataManager.SiteColumns.SelectAll(siteID); rUserColumnValues.DataBind(); } }