示例#1
0
        public void CustomTrackUrls(string MailingID)
        {
            CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(MailingID));
            CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
            if (objCampMaster != null)
            {
                CustomLabel objCustomLabel1 = new CustomLabel(ConnectionString);
                Int64 CampaignId = Convert.ToInt32(MailingID);
                Int64 TemplateId = Convert.ToInt64(objCampMaster.TemplateId);
                DataTable CusLabel = objCustomLabel1.getCustomLabel(TemplateId, CampaignId);
                htmlContent = objCampMaster.HTMLContent;
                string linkids = string.Empty;
                #region this logic will add click link to the content
                if (htmlContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = htmlContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE") && (linkID != "NewLink") && (linkID != "ExLink") && (linkID != "DeclineLink"))
                        {
                            linkids = linkids + linkID + ",";
                        }
                    }
                }
                if(linkids.EndsWith(","))
                 linkids = linkids.Substring(0, linkids.Length - 1);
                if (linkids.Trim().Length > 0)
                {
                    con = new SqlConnection(ConnectionString);
                    SqlDataAdapter da = new SqlDataAdapter(" select * from LinkDetails where ID in (" + linkids + ")", con);
                    DataSet linkset = new DataSet();
                    da.Fill(linkset);
                    grdLinkDetails.DataSource = linkset;
                    grdLinkDetails.DataBind();
                }
                else
                    lblMsg.Text = "No Links Found";
                #endregion

            }
            else
                lblMsg.Text="Mailing with ID "+hdMailingID.Value+" not exist";
        }
示例#2
0
        public void insertCustomLabel(CustomLabel objCustomLabel)
        {
            try
            {
                using (DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString))
                {
                    bool ExecutionState = false;
                    oDatabaseHelper.AddParameter("@CampaignId", objCustomLabel.CampaignId);
                    oDatabaseHelper.AddParameter("@TemplateId", objCustomLabel.TemplateId);
                    oDatabaseHelper.AddParameter("@LinkURL", objCustomLabel.LinkURL);
                    oDatabaseHelper.AddParameter("@CustomLabel", objCustomLabel.CustomLabel);

                    oDatabaseHelper.ExecuteScalar("sp_CustomLabel", ref ExecutionState);
                    int CampaignID = (int)oDatabaseHelper.GetParameterValue("@CampaignID");
                    oDatabaseHelper.Dispose();

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void insertCustomLabel()
        {
            if (hiddenCampaignID.Value != string.Empty)
            {
                CustomLabel objCustomLabel = new CustomLabel(ConnectionString);

                objCustomLabel.CampaignId = Convert.ToInt64(hiddenCampaignID.Value);
                objCustomLabel.TemplateId = (ddlTemplate.SelectedItem.Value != defaultListItem) ? Convert.ToInt64(ddlTemplate.SelectedItem.Value) : 0;
                Custom_URL.Value = Custom_URL.Value.Substring(1);
                Custom_URL.Value.Replace("\r\n", "");
                Custom_URL.Value.Replace("\\", "");
                Custom_Label.Value = Custom_Label.Value.Substring(1);
                objCustomLabel.Delete();
                string[] UrlFound = Custom_URL.Value.Split('|');
                string[] LabelFound = Custom_Label.Value.Split('|');
                for (int i = 0; i < UrlFound.Length; i++)
                {
                    objCustomLabel.LinkURL = UrlFound[i];
                    objCustomLabel.CustomLabel = LabelFound[i];
                    objCustomLabel.Insert();
                }
                Custom_URL.Value = string.Empty;
                Custom_Label.Value = string.Empty;
            }
            else
            {
            }
        }
        public void CustomTrackUrls()
        {
            if (hiddenCampaignID.Value == string.Empty)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please save the Mailing to avail this option.')", true);
            }
            else
            {
                bindTemplates();
                CustomLabel objCustomLabel1 = new CustomLabel(ConnectionString);
                Int64 CampaignId = Convert.ToInt32(hiddenCampaignID.Value);
                Int64 TemplateId = (ddlTemplate.SelectedItem.Value != defaultListItem) ? Convert.ToInt32(ddlTemplate.SelectedItem.Value) : 0;
                DataTable CusLabel = objCustomLabel1.getCustomLabel(TemplateId, CampaignId);
                string customLabelingDivContent = "<table widht=\"670px\"><tbody><th widht=\"200px\" Align=\"left\"><B>Label</B></th><th widht=\"470px\" Align=\"left\"><B>URL</B></th>";
                htmlContent = RadEditor1.Content;
                #region this logic will add click link to the content

                if (htmlContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = htmlContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE"))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                if (linkData.LinkURL.ToLower().Contains("http://"))
                                    linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                LinkURL = linkData.LinkURL;
                                if (linkData != null)
                                {
                                    if (htmlContent.ToLower().Contains(linkID))
                                    {
                                        htmlContent = htmlContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                    }

                                }
                            }
                        }

                    }

                }

                #endregion

                string textContent = textRadEditor.Content;

                #region this logic will add click link to the content

                if (textContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = textContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE"))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                if (linkData.LinkURL.ToLower().Contains("http://"))
                                    linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                LinkURL = linkData.LinkURL;
                                if (linkData != null)
                                {
                                    if (textContent.ToLower().Contains(linkID))
                                    {
                                        textContent = textContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                    }

                                }
                            }
                        }
                    }
                }
                #endregion

                if (textContent != string.Empty)
                {
                    textContent = textContent.Replace("&quot;", "\"");
                    textContent = textContent.Replace("&lt;", "<");
                    textContent = textContent.Replace("&gt;", ">");
                }
                if (htmlContent != string.Empty)
                    HTMLlist = LinkFinder(htmlContent);
                if (textContent != string.Empty)
                    Textlist = LinkFinder(textContent);

                if (Textlist.Count > 0)
                    HTMLlist = HTMLlist.Concat(Textlist).ToList();

                List<string> URLlist = new List<string>();
                for (int i = 0; i < HTMLlist.Count; i++)
                {
                    URLlist.Add(HTMLlist[i].Href);
                }
                URLlist = URLlist.Distinct().ToList();
                if (CusLabel.Rows.Count != URLlist.Distinct().ToList().Count && CusLabel.Rows.Count > 0)
                {

                    for (int i = 0; i < CusLabel.Rows.Count; i++)
                    {
                        for (int j = 0; j < URLlist.Count; j++)
                        {
                            if (URLlist[j] == CusLabel.Rows[i]["LinkURL"].ToString())
                                URLlist.RemoveAt(j);
                        }
                    }
                    if (URLlist.Count > 0)
                    {
                        for (int i = 0; i < URLlist.Count; i++)
                        {
                            string txtBoxId = "txt" + i;
                            string divId = "div" + i;
                            customLabelingDivContent += "<tr widht=\"670px\"><td widht=\"200px\"><input type=\"text\" id='" + txtBoxId + "'runat=\"server\" value='" + URLlist[i] + "'></td><td><div id='" + divId + "'style=\"width:470px; word-wrap: break-word\">" + URLlist[i] + "</div></td></tr>";
                        }
                    }
                }
                if (CusLabel.Rows.Count != 0)
                {
                    for (int loopcount = 0; loopcount < CusLabel.Rows.Count; loopcount++)
                    {
                        string txtBoxId = "txt" + loopcount;
                        string divId = "div" + loopcount;
                        string str = string.Empty;
                        string url = string.Empty;

                        str = CusLabel.Rows[loopcount]["CustomLabel"].ToString();
                        url = CusLabel.Rows[loopcount]["LinkURL"].ToString();
                        customLabelingDivContent += "<tr widht=\"670px\"><td widht=\"200px\"><input type=\"text\" id='" + txtBoxId + "'runat=\"server\" value='" + str + "'></td><td><div id='" + divId + "'style=\"width:470px; word-wrap: break-word\">" + url + "</div></td></tr>";
                    }
                    customLabelingDivContent += "</tbody></table>";
                    customLabeling.InnerHtml = customLabelingDivContent;
                    customLabeling.Visible = true;
                }
                else if (URLlist.Count > 0)
                {
                    for (int i = 0; i < URLlist.Count; i++)
                    {
                        string txtBoxId = "txt" + i;
                        string divId = "div" + i;

                        customLabelingDivContent += "<tr widht=\"670px\"><td widht=\"200px\"><input type=\"text\" id='" + txtBoxId + "'runat=\"server\" value='" + URLlist[i] + "'></td><td><div id='" + divId + "'style=\"width:470px; word-wrap: break-word\">" + URLlist[i] + "</div></td></tr>";

                    }
                    customLabelingDivContent += "</tbody></table>";
                    customLabeling.InnerHtml = customLabelingDivContent;
                    customLabeling.Visible = true;
                }
                else
                { customLabelingDivContent += "<tr><td> No Links Found</td></tr>"; }


            }
        }